In Linux, avoid using rm to accidentally delete files-lost memories-blog Bus
Avoid accidental deletion of files with rm in Linux: | category: Linux
Copyright Disclaimer: During reprinting, please use hyperlinks to indicate the original source and author information of the article and this statement
Http://freakrobot.blogbus.com/logs/88281920.html
Because most linux hair styles already use the ext3/4 file system, and because the files deleted by the rm command are not in the garbage bin, the files deleted by mistake by rm cannot be recovered.
Q: How can I recover (undelete) deleted files from my ext3 partition?
Actually, you can't! This is what one of the developers, Andreas Dilger, said about it:
In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out of the block pointers in the inode, whereas ext2 just marks these blocks as unused in the block bitmaps and marks the inode as "deleted" and leaves the block pointers alone.
Therefore, we should try to avoid accidental deletion of the file. We should create a new command del script to delete the file, store the following script under/usr/bin, and use it to delete the file in the future:
#!/bin/bashmkdir~/.Trash &> /dev/nullwhile [ ! -z "$1" ]; do mv "$1" ~/.Trash/ shiftdone