Article Title: prevent accidental deletion of important files: Safe-rm. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
It is very easy to delete files by mistake on the console. This is a painful experience. In a twinkling of an eye, important files are wiped out ...... If you accidentally delete the system file, you can reinstall it. If you accidentally delete your documents, you will be crying.
Although it can be alias rm = 'rm-I ', a dazzling or-rf can easily crash this fragile line of defense.
Safe-rm can provide protection for important file directories. It is actually an encapsulation of rm commands. Before executing real rm operations, first, check whether the Directory and file are in the protection list. If yes, discard the file and print an error message ~
You can download the Safe-rm package here. decompress the package and a safe-rm executable file is generated. Copy the package to/usr/local/bin, you can use the safe-rm command to delete files. The usage and parameters are the same as those of rm.
Of course, it is best to replace the system's default rm command so that even users who do not know safe-rm can be protected. Just make a symbolic link of rm:
Ln-s/usr/Local/Bin/safe-rm/usr/Local/Bin/rm |
Then, make sure that/usr/local/bin is in the PATH of the environment variable before other paths:
PATH =/Usr/Local/Bin:/usr/bin |
In this way, the rm Command actually calls the safe-rm command.
The safe-rm command uses two configuration files:
// Etc/safe-rm.conf
~ /. Safe-rm
The list of protected files is global and user. You only need to enter the complete path of important files or directories. Each file is separated by a carriage return.
For example ~ /. Write in safe-rm:
/Home/galeki/mywork /Home/galeki/mydoc |
In this way, the mywork and mydoc directories in my home directory will not be deleted. If you forcibly execute rm-R mywork, the following error occurs:
Safe-rm home: http://code.google.com/p/safe-rm/