Is there a command to recover/undelete deleted files by rm?$ rm -rf /path/to/myfileHow can I recover myfile? If there is such a tool how can I use it?
Unix/Linux undelete/recover deleted files
linux;data recovery;deleted files
The link someone provided in the comments is likely your best chance.Linux debugfs Hack: Undelete FilesThat write-up though looking a little intimidating is actually fairly straight forward to follow. In general the steps are as follows:Use debugfs to view a filesystems log$ debugfs -w /dev/mapper/wks01-rootAt the debugfs promptdebugfs: lsdelSample outputInode  Owner  Mode    Size    Blocks   Time deleted23601299      0 120777      3    1/   1 Tue Mar 13 16:17:30 20127536655      0 120777      3    1/   1 Tue May  1 06:21:22 20122 deleted inodes found.Run the command in debugfsdebugfs: logdump -i <7536655>Determine files inode..........output truncated    Fast_link_dest: bin    Blocks:  (0+1): 7235938  FS block 7536642 logged at sequence 38402086, journal block 26711    (inode block for inode 7536655):    Inode: 7536655   Type: symlink        Mode:  0777   Flags: 0x0   Generation: 3532221116    User:     0   Group:     0   Size: 3    File ACL: 0    Directory ACL: 0    Links: 0   Blockcount: 0    Fragment:  Address: 0    Number: 0    Size: 0    ctime: 0x4f9fc732 -- Tue May  1 06:21:22 2012    atime: 0x4f9fc730 -- Tue May  1 06:21:20 2012    mtime: 0x4f9fc72f -- Tue May  1 06:21:19 2012    dtime: 0x4f9fc732 -- Tue May  1 06:21:22 2012    Fast_link_dest: bin    Blocks:  (0+1): 7235938No magic number at block 28053: end of journal.With the above inode info run the following commands# dd if=/dev/mapper/wks01-root of=recovered.file.001 bs=4096 count=1 skip=7235938# file recovered.file.001file: ASCII text, with very long linesFiles been recovered to recovered.file.001.Other optionsIf the above isn't for you I've used tools such as photorec to recover files in the past, but it's geared for image files only. I've written about this method extensively on my blog in this article titled: How to Recover Corrupt jpeg and mov Files from a Digital Camera's SDD Card on Fedora/CentOS/RHEL.