How to Recover Deleted Files in Linux (Mint, Ubuntu, etc.)?

avatar
Zoey Wen
May 17, 2024 Preview 537 Preview 0
share it facebook share it Twitter

Linux is a developer-friendly operating system, with approx 4% market share and this number continues goes up. It is designed for development environments, because it has the highest stability and reliability to deal with high workloads. There are many Linux distros tailored for different usage, such as Mint, Ubuntu, Nitrux, etc. And you can install Linux on a server or via virtual machine.

While running Linux on your machine, no matter on a PC, Mac or others, accidentally deleting files is not uncommon. In this guide, we will show you how to recover recently or permanently deleted files in Linux Mint, Ubuntu or other distributions. 

Is It Possible to Recover Deleted Files in Linux?

Yes, it is.

Like other operating systems, Linux is loaded and run on a disk that offers enough space to write and read data. Though unlike macOS or Windows that saves files in a folder, Linux saves its files in the root directory. When a file is deleted from Linux, it becomes invisible in the root directory because the link to this file is removed, but it is still stored in the original space, until there is new data written to Linux and replace. Therefore, as long as the deleted file is not overwrite by new data, it is still possible to recover, using commands or professional data recovery programs.

Where Do Deleted Linux Files Go?

There are a lot of Linux distros, if you are using a distribution that has a desktop environment and deleted the files by moving to Trash bin without further deletion, the files will be kept in recycle bin until the disk becomes full.

If you don’t use the desktop environment and deleted the files with rm command on a PC or Mac, the files won’t be moved to recycle bin, because there is no recycle in on your device. Though you cannot find the deleted files under this situation, they are still stored on your Linux, until they are overwritten by new data. 

How to Recover Deleted Files in Linux?

In exploring the recovery of deleted Linux files, we should consider how the files were deleted. And before restoring the files, we need to unmount the partition where the deleted files were stored. This stops new data overwriting the deleted files and increases the chances of a file recovery, here is how:

Find the terminal launcher in your Linux distribution and enter the following commands:

sudo umount /dev/sdXY

sudo mount -o ro /dev/sdXY /media/read-only

You need to replace X with your Linux drive letter (A/BC/...) and Y with the Linux partition identifier(1/2/3/...) that stored the deleted files.

Now, we will look at 4 ways to recover deleted Linux files, with or without commands.

1. Use Cisdem Data Recovery

If you have installed SSH service on Linux, you can remotely connect to the Linux server and recover the deleted files with ease, by using Cisdem Data Recovery.

Cisdem Data Recovery Windows is designed to recover recently & permanently deleted, lost, formatted, damaged, even unsaved files from both internal hard drive and external storage device that connects with the PC. Being a reliable data recovery program, it applies to different data loss scenarios and supports a lot of file types. What makes it excel others is its rich recovery modes, in the latest V18.0.0, it add support for Linux recovery.

Main Features of Cisdem Data Recovery

  • Recover files from PC internal disk
  • Restore files from external hard drive, SD card, NAS, Linux and so on
  • Recover data from crashed PC
  • Support 1000+ file types: video, photo, audio, document, email, archive, others.
  • Recover damaged videos and photos automatically
  • Restore unsaved Word, Excel, PowerPoint, etc.
  • Preview files before recovery
  • Highly compatible with Windows 11/10/8/7

How to Recover Recently or Permanently Deleted Files in Linux with Cisdem?

  1. Download and install Cisdem Data Recovery on your PC.
    Free Download Windows 11/10/8/7
  2. Go to Advanced Recovery > NAS & Linux > Linux Recovery.recover linux cisdem01
  3. Enter the user name and password, then click Connect Now.recover linux cisdem02
  4. You will be able to access to your Linux device. After the scanning, go to Path or Type, search and locate the Linux files.recover linux cisdem 03
  5. Preview the files, select and click Recover.recover linux cisdem03

 

2. Restore Lost Linux Files from Recycle Bin

If you are using a Linux distribution with desktop environment,such as Ubuntu, the deleted files will be moved to the trash folder, you just need to open the Trash app and put the files back.

  1. Open the Trash app.
  2. Select the deleted files, right click and choose Restore From Trash.recover linux trash

 

3. Undelete Linux Files with Terminal or Command

If your Linux distribution doesn’t come with a desktop environment, you can undelete Linux files using commands in Terminal or other command launchers on your device, but you have to install Linux a data recovery program. Luckily, there are so many free Linux data recovery apps for your option, here we recommended the best 2: Foremost and Test Disk.

#1 Use Foremost

  1. Open a terminal in the command launcher on your device, you should use the root user.
  2. Enter # foremost -t all -v -q -i /dev/sdb2 -o /home/kali/desktop/recover, press Enter. Here b refers to your Linux disk, 2 refers to the partition identifier where your files are deleted from. You need to replace with your own ones.foremost linux01
  3. Enter Y and press Enter to install Foremost on your Linux device, then clear the terminals.
  4. Enter # foremost -h and press Enter to learn the parameter’s meaning.foremost linux02
  5. Enter # foremost -t all -v -q -i /dev/sdb2 -o /home/kali/desktop/recover, press Enter. Here desktop is the location where your recovered files will be saved, and recover is the folder name where you recovered files are saved, you can change to your own ones. Also, you don’t have to recover "all" files, you can only recover specific files by entering the file types.foremost linux 03
  6. Then checked the recovered files in the output folder.

 

#2 Use TestDisk

  1. Open a terminal in the command launcher on your device.
  2. Enter sudo apt-get install testdisk -y, press Enter.testdisk recovery linux 01
  3. Enter your password and the installation will start.
  4. Type mkdir ~/recovery, press Enter; type cd ~/recovery, press Enter; type sudo testdisk, press Enter. Testdisk will be launched for the recovery.testdisk recovery linux 02
  5. Use arrow keys to create a new log file or just skip this step. Press Enter.
  6. Select the Linux drive to scan files, press Enter.testdisk recovery linux 03
  7. Select the Linux partition table type, press Enter.testdisk recovery linux 04
  8. Select Advanced and press Enter.testdisk recovery linux 05
  9. Select the Linux partition that you’ve deleted the files, press Enter.testdisk recovery linux 06
  10. Select List using the arrow keys.
  11. Select the directory that stored the deleted files and press Enter, then select the deleted files under this directory.testdisk recovery linux 07
  12. Press C to recover the deleted files.
  13. Then use the arrows keys to Quit TestDisk and check the recovered files in the recovery directory. Here our files are recovered to "recovery" folder.

 

4. Recover Linux Files with Backup

Or if you have a backup for the Linux files, on external hard drive or up in the cloud, you can restore the deleted Linux files via the backup.

#1 Use Time Machine on Mac

Time Machine is the free backup and restore utility on Mac, if you have enabled this feature on your device, it is possible to restore the deleted Linux files from the backup.

  1. Connect the Time Machine backup drive to your Mac.
  2. Click on Time Machine icon and Enter Time Machine.recover linux time machine 01
  3. Find the deleted Linux files and select a version from the timeline.recover linux time machine 02
  4. Click Restore. recover linux time machine 03

 

#2 Use File History on PC

On Windows, the backup and restore utility is File History, if you have enabled the auto backup feature in this tool, you will be able to restore the lost Linux files from the backup.

  1. Connect the File History backup drive to your PC.
  2. Open File History, then select Restore personal files. recover linux file history
  3. Find the deleted Linux files, also you can choose a version from the history.
  4. Select the files and click the Recover button.

 

#3 Use Google Drive (iCloud/OneDrive)

If you have uploaded a copy of the Linux files to your Google Drive or other cloud storage accounts, you can sign in those services and re-download the deleted files to your device. Here we take Google Drive as an example.

  1. Log into Google Drive account.
  2. Go to My Drive, select the files that you’ve deleted from your Linux device, then click Download.recover linux google backup
  3. Also, don’t forget to check the Trash folder if you cannot find a deleted Linux file.

 

Conclusion

Recovering deleted files from Linux can be different from each other according to the Linux distros, if yours are the same as in our recovery process, just follow the steps. But if you are using other Linux distros and don’t how to restore the files, you can leave us a message in the comment, we will get back to you as soon as possible. Or actually, as long as you know the syntax to restore files with commands on Linux, it is quite easy for Linux file recovery, also, there are many video tutorials on YouTube for your reference.

avatar
Zoey Wen

Zoey shows a great interest in what she does. Although not long with Cisdem, she has possessed a professional understanding of data recovery.

Loved the article, share!
Comments (0) Leave a Reply

Name *

Comment *

Hot Articles

How to Recover Permanently Deleted Folder That Not in Recycle Bin on Windows 10/11? Illustrator Could Partially Read This File? How to Recover AI File with Ease? How to Use Recuva for Android Phone and Recover Files (2024 Update)
Home > How to Recover Deleted Files in Linux (Mint, Ubuntu, etc.)?