How do I recover from an Ubuntu system that uses RM commands to delete files?
If it is a EXT3/EXT4 file system, you can use the Extundelete tool to recover.
$ df-ht File system type capacity used available% mount point/dev/sda1 ext4 455G 366G 66G 85%/
Reference article:
1. http://longgeek.com/2012/11/25/extundelete-recovery-for-linux-ext2-ext3-ext4-rm-rf-accidental-deletion-of-data/
2. http://www.linuxyunwei.com/2012/08/ext4%E4%B8%AD%E6%81%A2%E5%A4%8D%E4%BD%BF%E7%94%A8rm%E5%91%BD%E4%BB%A4%E8% af%af%e5%88%a0%e9%99%a4%e7%9a%84%e6%96%87%e4%bb%b6/
Second, after installing Ubuntu, the RM command should be replaced by aliases.
The Replace RM command is the MV command, and the file to be deleted is moved to a custom folder to prevent accidental deletion.
The code is as follows:
1. Create a new directory under/home/username/ directory, named:.trash2. in/home/username /tools/directory, create a new shell file named: remove.sh. The contents are as follows: para_cnt=$ #TRASH_DIR = "/home/username/.trash" for i in $*; do stamp= ' date +%s ' filename= ' basename $i ' mv $i $TRASH _dir/$fileName. $STAMPdone 3. Modify ~/.bashrc, Add a line alias rm= "Sh /home/username/tools /remove.sh "Use our self-built remove.sh to replace the RM command 4. set up crontab, periodically emptying the trash bin, such as: 0 0 * * * RM -RF /home/username/.trash/* emptying the trash bin at 0 o ' 5. source ~/.bashrc every day to make the replacement take effect immediately after the above steps, execute RM deleted files, will be put into the trash bin. If deleted by mistake, you can recover from it. 6. because ~/.BASHRC this file is not valid for the root user, so also to modify the/ETC/BASH.BASHRC, this file has a global effect. in the last line add: alias rm= "sh /home/username/tools/remove.sh"
In this way, the RM command is converted to the MV command, which can achieve the desired effect, except that an error is reported in the habitual typing- r parameter because the MV command does not have the-r parameter.
This article is from the "Cool Ice" blog, please make sure to keep this source http://liangbing8612.blog.51cto.com/2633208/1590128
Use RM command to delete files under Ubuntu system