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