Prevent accidental deletion of important files: Safe-rm

Source: Internet
Author: User
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/

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.