Linux Restore mistakenly deleted files

Source: Internet
Author: User
Tags root access

1 Get root access switch root
2 Install E2fsprogs, some Linux comes with, some do not own, need to install
3 Debugfs/dev/sda3 (the file is in the same partition)
4 Wait until debugs: Enter Lsdel (lists the deleted files) please wait
5 depending on the deletion time, find the inode number of the file
6 Dump <inode >/xx/xx/file
Do not modify and write the file once it has been mistakenly deleted, because it is restored immediately to prevent the inode of the deleted file from being overwritten
You should pay attention to the RM later. To avoid this situation again, write a script to transform RM into a move into the Recycle Bin, similar to Windows, to execute directly in Bash_profile.

    1. Mkdir-p ~/.trash
    2. Alias Rm=trash
    3. Alias R=trash
    4. Alias rl=' ls ~/.trash ' //RL command to display files in recycle bin
    5. Alias ur=undelfile //ur command to retrieve files from recycle bin
    6. Undelfile () //Retrieve the files under the Recycle bin
    7. {
    8. Mv-i ~/.trash/\[email protected].
    9. }
    10. Trash ()
    11. {
    12. MV [email protected] ~/.trash/
    13. }
    14. Cleartrash ()
    15. {
    16. Read-p "Clear sure?[ N] "Confirm
    17. [$confirm = = ' y '] | | [$confirm = = ' Y '] &&/bin/rm-rf ~/.trash/*
    18. }

Linux Restore mistakenly deleted files

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.