Rm-rf is more careful when using commands. it often goes by the river. it is inevitable that the shoes will be wet. yesterday, a wrong hand, wrong command, put the folder you originally wanted to keep to rm-rf for a few days of painstaking efforts, rely on, and the heart of death has gone through Baidu, google, and try to be fruitless, ah, how can I find it later... capital
Rm-rf use with caution
The command has been knocked a lot. it often goes by the river, and it is inevitable that the shoes will be wet.
Yesterday, by mistake, I typed the wrong command and gave the folder to rm-rf.
A few days of hard work, relying on, the heart of death
Baidu, google, and fail to get it back.
Lessons:
1. be careful before rm, especially rm-rf, or simply rewrite the command.
2. make backup and have convenient backup scripts
3. make a regular backup. one of our predecessors has a regular script and runs it on a regular basis every day. even if a mistake is deleted, it will not be so miserable.
First, create a recycle bin.
In ~ Add. bashrc or. bash_profile
Mkdir-p ~ /. Trash
Alias rm = trash
Alias r = trash
Alias rl = 'ls ~ /. Trash'
Alias ur = undelfile
Undelfile ()
{
Mv-I ~ /. Trash/$ @./
}
Trash ()
{
Mv $ @~ /. Trash/
}
This is the execution
Rm is equivalent to executing mv.
Note: rm-rf is already available.
The deleted file will appear in. trash.
Can be recovered
Ur filename
This poses a problem. how to delete the items in the recycle bin? this is a useful post-rm here.
Add a function under. bashrc just now.
Cleartrash ()
{
Read-p "clear sure? [N] "confirm
[$ Confirm = 'y'] | [$ confirm = 'y'] &/usr/bin/rm-rf ~ /. Trash /*
}
$ .. Bashrc
Then, if you want to clear the recycle bin
$ Cleartrash.
Backup Script in process
Including compress, fast backup, and midnight scheduled backup.
Delete files in linux and fix them. Currently, I have learned how to delete files.
Lessons learned from blood and prevention
From: wklken's note