Preface: rm under Linux system is irreversible. There is nothing wrong with the command design itself. The problem is that we are usually very confident and like to use rm -rf when executing. This is very dangerous. If the command is executed incorrectly or even the directory is executed incorrectly, it will cause a lot of trouble. At the least, it will lead to overtime work and waste of manpower and material resources. At the worst, it will affect the company's business and even lead to the risk of dismissal. The Recycle Bin mechanism under Windows is a very good strategy, but Linux does not have it. Then we can create one manually and execute it directly: mkdir -p ~/.Trash cat >>~/.bashrc<<EOF #add by caimengzhi at $(date +%F) for Linux trash start alias rm=trash alias rl='ls ~/.Trash' alias ur=undelfile undelfile() { mv -i ~/.Trash/\$@ ./ } trash() { mv \$@ ~/.Trash/ } cleartrash() { read -p "Clear trash?[n]" confirm [ \$confirm == 'y' ] || [ \$confirm == 'Y' ] && /usr/bin/rm -rf ~/.Trash/* } #add by caimengzhi at $(date +%F) for Linux trash end EOF source ~/.bashrc illustrate: 1. ~/.Trash is where deleted files and folders are moved to, that is, the Recycle Bin 2. \$confirm means to implement verification, which means that the last thing in the file is $confirm. Among them, \$@ is the same 3. The above function, to put it simply, is to rename the command rm. Use syntax: rm (delete), ur (undo), rl (list recycle bin), cleartrash (empty recycle bin) commands.
OK, that's the basic content. In essence, it just replaces the root user's rm command with the mv command. If the system has established other users, you also need to use that user to re-execute the above command. It depends on the situation. If you lose the root privilege, then the power of rm -rf is nothing to be afraid of. Of course, we also need to execute the regular rm command. How to do it? This is ok: The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
>>: Detailed explanation of mixins in Vue.js
The specific upgrade script is as follows: Dynami...
In the past, I used to directly order by rand() t...
Table of contents Preface 1. Trigger Overview 2. ...
1. Download address https://dev.mysql.com/downloa...
Join uses the Nested-Loop Join algorithm. There a...
Table of contents Essential Difference Database s...
Table of contents 1. Build local storage 2. Creat...
Table of contents Written in front Environment de...
If you cannot download it by clicking downloadlao...
Table of contents Introduction effect principle f...
Table of contents Intro Nginx Dockerfile New conf...
Some projects have relatively simple business, bu...
1. Add a new user Only allow local IP access crea...
Method 1: Use the SET PASSWORD command First log ...
This article uses an example to describe how to u...