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.
mv [email protected] /tmp/trash_tmp
: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:
/bin/rm -i <文件名>
Cloud Server ECS Linux system Add "Recycle Bin"