Simple precautions for a Linux user

Last modified 28 Sep 2007.

Things are bound to go wrong. You will accidentally delete a whole directory. Or some windows program will overwrite the master boot record. Here are some simple advance measures to help your system survive Murphy's law:

  1. Make a GRUB boot disk

    If you use grub as your boot loader, you can make a boot disk by installing grub on a floppy:
     > grub-install '(fd0)'
     
    Now you can boot off the grub floppy.
  2. Back up regularly

    The easiest way is to synchronize your files with a remote filesystem on another computer, via rsync. Here is a general-purpose driver script called rsynchro which synchronizes a given list of files rsynchro.lis between a local and remote machine.
  3. Use a safe deletion command instead of rm

    Create a wastebasket directory, e.g. ~/.wastebasket, and define the aliases
    alias rm 'echo "Use rem for reversible delete, \\rm  for regular delete"'
    alias rem '\mv -t ~/.wastebasket'
    
    Now you always type "rem file1 file2 ..." to delete files. If you need the original rm command, you can still get it by typing "\rm". You will quickly get used to typing "rem" instead of "rm", and before long you will thank yourself for making the effort. Just remember to empty your wastebasket directory occasionally.
  4. Make mv and cp safer

    Alias them to safer versions that prompt before overwriting, and create a backup of what they overwrite:
    alias mv 'mv -i -b'
    alias cp 'cp -i -b'
    
  5. Install the recover command

    recover is available from RPM repositories and SourceForge. If you realize you have accidentally deleted something, run recover (as root) and it will help you search through the deleted files to find it.

Mark Alford's home page

alford(at)wuphys.wustl.edu

Valid XHTML 1.0!