Preventing Data Loss (File Deletion)
ITS encourages you to take measures to prevent loss of data. These measures include using the -i option with the
rm, mv and cp commands. Also, you should create backup
disks of important files. Both of these measures will help prevent accidental loss of data.
If your account resides on an ITS-owned machine, and your UserLevel is set to novice, the
rm, cp, and mv commands are aliased to include -i by default. This is true only for ITS-owned machines, and not UNIX in general.
This file will tell you how to set up aliases so that the commands listed above will operate in interactive mode. You can check to see what aliases you are using by typing:
alias
If the list of aliases includes something which looks like:
rm rm -i
then you already have an alias set up to force the command to ask you for permission before deleting.
For all intents and purposes, when you delete a file with rm
it is gone. The system actually forgets which blocks of data, scattered
around the disk, comprised your file. The only way to retrieve such a
file is by requesting a UNIX restoral. Please see the ITS Operational Procedures for more information.
To use rm with the -i option:
rm -i <filename>
where <filename> is the name of the file(s) that you would
like to delete. This is the interactive option. You must confirm the
deletion by
typing y for each file or n to skip the file. E.g:
% rm -i prog*.c
rm: remove prog1.c? y
rm: remove prog2.c? n
rm: remove prog3.c? y
rm: remove prog4.c? n
%
You can redefine the rm command to use this option with the command:
alias rm 'rm -i'
With the above alias, whenever you use rm, it will actually execute in your .cshrc
file.
You can also use the interactive option with other commands like cp and mv. Whenever the
use of one of these programs would cause an existing file to be overwritten, then the -i option will cause it to prompt you
for confirmation.
If you have the above alias definition in your .cshrc file you can override it either by typing in the full pathname of
'rm':
/bin/rm filename
or by using unalias to get rid of the rm alias for that current
session:
dunalias rm
Note: When you log in again, the rm alias will once again be defined as it
appears in your .cshrc file.
Last updated:
February 03, 2011