Cloud Server ECS Linux system Add "Recycle Bin"

Source: Internet
Author: User

 

Deletion is an operation with high risk factors, which can cause an unpredictable loss if deleted by mistake. This danger is particularly noticeable in ECS Linux systems on cloud servers. For example, a simple statement: RM–RF/* will remove the entire system, and Linux will not refuse to execute because of the unreasonable statement.

In Windows, the system provides the Recycle Bin functionality by default in order to prevent accidental deletion. After the user performs the delete operation, the file is not deleted directly from the hard disk, but is placed in the Recycle Bin. Before emptying the Recycle Bin, users can restore the files in the Recycle Bin to their original location if they are found to have been deleted by mistake. While Linux does not provide similar functionality, the DELETE command RM once confirmed execution, the file will be deleted directly from the system, it is difficult to recover.

This paper takes the CentOS6.5 system environment as an example to create a simple Recycle Bin function for Linux.

1. Create a new Recycle Bin directory.

2. Vim/bin/trash Edit a file.

    1. mv [email protected] /tmp/trash_tmp
    2. :wq 保存退出

3. alias rm=/bin/bash add aliases.

4. At the bottom of the/ETC/BASHRC file, add the content shown in the diagram.

5. sOURCE/ETC/BASHRC enable environment variables.

6. Test Delete file A.txt, as a result, after the RM command is executed, it is found that the A.txt file has been placed in the Recycle Bin directory at the beginning of the setup.

If you really want to delete a file by the following way:

    1. /bin/rm -i <文件名>

Cloud Server ECS Linux system Add "Recycle Bin"

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.