How to recover data / folder deleted with rm -rf ?

Today Accidentally I deleted one of my folder in ubuntu which has contained important files, but I wanted to copy those to another machine by tarring it, while there was another archive / tar with same name, I wanted to delete that .tar but deleted folder resulting deleting very important files.

To recover those files immidiately I used following commands,

$ sudo apt-get install extundelete 

Now check where the hard disk is mounted using df -h command, in our case it was at /dev/sda1

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G   12K  1.9G   1% /dev
tmpfs           387M  700K  386M   1% /run
/dev/sda1       455G  210G  222G  49% /
$ sudo extundelete --restore-directory /home/myuser/path-of-deleted-folder/deleted-folder-name /dev/sda1

password for myuser:
WARNING: Extended attributes are not restored.
The partition should be unmounted to undelete any files without further data loss. If the partition is not currently mounted, this message indicates it was improperly unmounted, and you should run fsck before continuing. If you decide to continue, extundelete may overwrite some of the deleted files and make recovering those files impossible. You should unmount the file system and check it with fsck before using extundelete. Would you like to continue? (y/n) y Loading filesystem metadata … 3695 groups loaded. Loading journal descriptors … 29653 descriptors loaded. Writing output to directory RECOVERED_FILES/ Searching for recoverable inodes in directory /ho/home/myuser/path-of-deleted-folder/deleted-folder-name … 1276 recoverable inodes found. Looking through the directory structure for deleted files … Restored inode 23071241 to file RECOVERED_FILES/home/myuser/path-of-deleted-folder/deleted-folder-name/myfile1.txt Restored inode 23070734 to file RECOVERED_FILES/home/myuser/path-of-deleted-folder/deleted-folder-name/myfile2.csv Restored inode 23071394 to file RECOVERED_FILES/home/myuser/path-of-deleted-folder/deleted-folder-name/myfile.pdf 1266 recoverable inodes still lost.

Now you should have RECOVERED_FILES new folder created in your working directory and it will have all recovered folder and files along with relative path.

Terra Station To Kucoin (IN 3 STEPS) x
Terra Station To Kucoin (IN 3 STEPS)

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto Embedded Linux