Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Undelete - Removed file using 'rm'

  1. #1
    Join Date
    Sep 2010
    Beans
    198
    Distro
    Xubuntu 11.04 Natty Narwhal

    Undelete - Removed file using 'rm'

    Hey,

    I've deleted a file using rm in bash, is there a way to 'undelete' it (like the DOS command of old)?

    Not a massive deal if I can't, but I think it would still be handy to know.

  2. #2
    Join Date
    Oct 2009
    Beans
    244

    Re: Undelete - Removed file using 'rm'

    rm deletes a file completely. It doesn't move it to a trash folder or anything like that. The only way to recover it would be to use a file recovery program like photorec. That's quite a lot of effort though if the file isn't that important. If you want to do this and need help post back here so we can give you a hand.
    Angus

  3. #3
    Join Date
    Sep 2010
    Beans
    198
    Distro
    Xubuntu 11.04 Natty Narwhal

    Re: Undelete - Removed file using 'rm'

    I think I'll pass on that - I've had to use photorec previously when I accidentally repartitioned the wrong drive; it is certainly not worth that effort.

  4. #4
    Join Date
    Mar 2010
    Beans
    8,758
    Distro
    Ubuntu Mate

    Re: Undelete - Removed file using 'rm'

    You might want to consider using the
    Code:
    mv
    command next time; that way if you mess things up you can always restore the file.

    See
    Code:
     man mv
    for details.

  5. #5
    Join Date
    Oct 2005
    Location
    United Kingdom
    Beans
    4,848

    Re: Undelete - Removed file using 'rm'

    I've used tools like photorec in the past to recover data and yes it can be a hassle but it got me everything back.

    There are other *easier* ways though depending on what filesystem you are using? Did you immediately shut down or are you using the machine/disk still? If so, the data might (probably has been) overwritten.
    Every time you install Jaunty, a kitten........ wait sorry what year is this again?
    Please don't PM support questions, post a thread so that everyone can benefit
    Join us in #ubuntuforums on irc.freenode.net

  6. #6
    Join Date
    May 2007
    Location
    Virginia, USA
    Beans
    13,348
    Distro
    Ubuntu Mate Development Release

    Re: Undelete - Removed file using 'rm'

    Quote Originally Posted by da burger View Post
    rm deletes a file completely.
    Technically, it does not delete a file "completely". If it did, tools like photorec could not recover the file.

    It doesn't move it to a trash folder or anything like that.
    Now, this is true.

    If you want to delete a file "completely", meaning, so that it can not be recovered, then use "shred".

    Yeah, I'm nitpicking ... but folks need to be made aware that to completely remove files and their contents, they need to use something other than "rm".
    Ubuntu 20.04, Mint 19.10; MS Win10 Pro.
    Will not respond to PM requests for support -- use the forums.

  7. #7
    Join Date
    Oct 2009
    Beans
    244

    Re: Undelete - Removed file using 'rm'

    Quote Originally Posted by Mark Phelps View Post
    Technically, it does not delete a file "completely". If it did, tools like photorec could not recover the file.

    Now, this is true.

    If you want to delete a file "completely", meaning, so that it can not be recovered, then use "shred".

    Yeah, I'm nitpicking ... but folks need to be made aware that to completely remove files and their contents, they need to use something other than "rm".
    What I meant by that, and what I think can be reasonably inferred from what I said, was that it is totally removed from the file system. The only way to get it back is to have a program inspect the blocks that are not in use by the file system (like photorec). Depending on your definition of delete, what I said was perfectly accurate.

  8. #8
    Join Date
    Nov 2009
    Location
    Gainesville, VA
    Beans
    459
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: Undelete - Removed file using 'rm'

    Quote Originally Posted by Rubi1200 View Post
    You might want to consider using the
    Code:
    mv
    command next time; that way if you mess things up you can always restore the file.

    See
    Code:
     man mv
    for details.
    +1 here - Especially if you're not used to working within a command prompt. YOu can create a directory and move files there that you want to delete (it would work like a trash bin) then come back at the end of your session and make sure you want to run the rm command.

  9. #9
    Join Date
    Sep 2010
    Beans
    198
    Distro
    Xubuntu 11.04 Natty Narwhal

    Re: Undelete - Removed file using 'rm'

    Using mv as in moving it to another directory? That would require a designated 'trash' directory, and a conscious effort to keep it clean.

    In the event that I'm not sure I should be deleting the file, I usually use mv to rename the file to .backup, test what I need to test and then delete that.

  10. #10
    Join Date
    Nov 2009
    Beans
    Hidden!
    Distro
    Kubuntu 18.04 Bionic Beaver

    Re: Undelete - Removed file using 'rm'

    Quote Originally Posted by Mark Phelps View Post
    Yeah, I'm nitpicking ... but folks need to be made aware that to completely remove files and their contents, they need to use something other than "rm".

    makes sense, but why there is no command to undue the deleting? surely it should be easier in Linux since there is less disk fragmentation, yet we all know that DOS undelete can do it. as could unformat (or similar) back in the days return data from formated drive.
    Read the easy to understand, lots of pics Ubuntu manual.
    Do i need antivirus/firewall in linux?
    Full disk backup (newer kernel -> suitable for newer PC): Clonezilla
    User friendly full disk backup: Rescuezilla

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •