A little trick that some Linux users like to implement to prevent accidental file deletion is via the use of an alias. Aliases are similar to variables and can either be set in a session or by placing the alias command in the .profile or .bash_profile file with a text editor.

By adding this alias the user will be prompted to confirm each file before it is deleted; otherwise Linux, unlike Microsoft Windows, will delete whatever files match the filename criteria without warning!

$ alias rm='rm -i'
$ touch touch1.fil touch2.fil touch3.fil
$ rm touch*
rm: remove regular empty file `touch1.fil'? y
rm: remove regular empty file `touch2.fil'? y
rm: remove regular empty file `touch3.fil'? y

Easy Linux CommandsFor more tips like this check out my book Easy Linux Commands, only $19.95 from Rampant TechPress.

Buy it now!


linux, unix, system administration, sysadmin, bash