One level of guard in interactive shell

sigma-ml
  13 years ago
  1

This is not as much a real tutorial as it is a word of caution.  For a real tutorial, you could refer http://community.linuxmint.com/tutorial/view/100.

The three commands

  • cp
  • mv
  • rm

can make destructive changes to your system, in an irreversible manner.  Fortunately, all of them provide for a flag to prompt the user for confirmation before carrying out their tasks.

Having the following in your shell's resource file (or aliases file, for more advanced users) provides one level of guard against inadvertent damage.

alias cp='cp -i'

alias mv='mv -i'

alias rm='rm -i'

The above works for bash (the default in Mint), ksh and zsh.  The corresponding resource files are ~/.bashrc, ~/.kshrc and ~/.zshrc, respectively.

Enjoy a safer shell experience!

Comments
sigma-ml 13 years ago

I agree. At the same time, setting these aliases everywhere one has the authority to do so, does help. Perhaps LM could even set them by default, thereby setting a standard.

I think that this mini-word-of-caution-tutorial can be deleted, should these elements be incorporated into Justin's 5-minute tutorial.


justin 13 years ago

There are several discussions about these kinds of safeguards and if they are good. Hear me out, briefly. The reason for aliasing these is exactly the reason above, as a cautionary method. However, this is not the default behavior on any systems. Setting aliases like this leads to a false sense of security that something will be there to catch you, and on many boxes these aliases won't be set. It's a bad habit to expect these behaviors as they aren't the standard. It would be better to use the flags as part of the passed options during execution, imho.