In Linux, avoid using rm to accidentally delete files-lost memories-blog Bus

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.