How to Recover Deleted Files In Ubuntu?

Have you ever mistakenly deleted essential files in Ubuntu and later regretted it? We all did this at some stage, and we know it’s too late to regret it, as once deleted, the files are gone.

But, luckily with Ubuntu, the case is different. You can recover deleted files in Ubuntu. So, if you’ve accidentally erased crucial documents in your Ubuntu Linux system, this guide is just for you.

We’ll show you how to recover files in Ubuntu today. However, you may use this method to recover deleted files on any Linux platform.

Importance Of Recovered Files

Data recovery is very important not just for companies but also for individuals. The importance of recovered files is inevitable, and below we will take a look into a few of the most common reasons.

Deleting Files by Accident

When a computer has several users, this is common. It’s upsetting when you mistakenly erase a project after working on it for a long time, and you might also delete or edit a file or folder by accident. Always be cautious, especially when removing a large number of files.

If a computer has numerous users, it’s also a good idea to store your work in a designated folder, and, if feasible, you can also protect the file by password as extra precautions. So, data recovery will help you get files deleted due to accidental deletion.

Virus Attacks

As the number of people using the internet grows, so do the number of viruses and ransomware. A virus can specifically target files, folders, or your whole hard disk. Even if you use anti-virus software, viruses can still infect your files and cause harm. However, data recovery can help you retrieve these damaged files.

System Crash

Virus assaults, hot computers, full hard disks, full RAM, and other factors might cause a system crash. When this occurs, you will undoubtedly want data recovery software or services, as system crashes frequently result in the loss of vital files.

Key Takeaways

  • It is possible to recover deleted files in Ubuntu
  • You can find many different tools to recover deleted files in Linux
  • TestDisk is the most popular and commonly used data recovery tool for Ubuntu.
  • Data recovery is very important for bringing back important lost files.

Can Deleted Files Be Recovered In Ubuntu?

Yes, unlike other operating systems, files can be easily recovered in Ubuntu by the use of different methods and tools. All methods may not be helpful for you. So you will need to try other ways to see which one works best for you.

Can Deleted Files Be Recovered In Ubuntu

Ubuntu uses journaling file systems like ext4 by design. A journaling file system gets its name from the fact that it maintains track of which files are placed where on your drives.

So, deleting a file simply erases the file from the router interface. However, the main file remains inside the internal system. Undelete tools in Ubuntu

scour your file system for evidence of data deleted from the system files log but is still accessible on the disk. As a result, until new data replace the old data, you will be able to restore the data.

Undeleted files are also more likely to survive if they live on a partition outside of your primary system, as system partitions experience higher amounts of data flow from operating systems.

Keep in mind that it is impossible to tell for how long your data will remain intact as they get overwritten with new files for as fast as dew seconds or even can stay for years without being overwritten by new files.

On Ubuntu, the possibility of undeleting files is determined mainly by chance and the number of apps and processes active on your system: The more things you have running, the fewer chances you have in recovering deleted data.

Where Do Deleted Files Go In Ubuntu?

Deleted files normally follow the route shown below when files are discarded. They got:  ~/. Local < Share < Trash <Files.

Where Do Deleted Files Go In Ubuntu

When you remove an item in Ubuntu using the GUI manager, it is transferred to the Trash folder and stored there till you yourself clean the folder.

The rm command in Ubuntu is similar to the del command in Windows, which deletes files but does not send them to the Recycle Bin.

The directory entry is erased if you rm files from the command prompt or deactivate the item in scripting; if the directories record refers to some other file, there will be no change.

The link count in the inode is decremented if the directory entry refers to it. If the link count is 0, the inode is returned to the free list, together with all of the disk blocks that the inode references. The data in the blocks is not deleted until they are reassigned to another file.

If you decide you need anything from the Trash folder or unintentionally removed it, you can restore it to its original position. The procedure is very similar to those of other operating systems.

How To Recover Deleted Files In Ubuntu?

Even though there are many different tools and software available to recover fully deleted data from Ubuntu, not all of them work well; hence below, we will discuss three tested methods that you can use to recover deleted files on Ubuntu.

How to Recover Deleted Files In Ubuntu

PhotoRec

PhotoRec is an excellent data recovery tool for Ubuntu. You might think it’s just good for restoring photographs based on the name. However, this is not the case, as it is capable of recovering a variety of additional data formats.

How To Recover Deleted Files In Ubuntu using PhotoRec

It is very easy to install and run with a simple Photorec command. It will prompt you to choose the partition containing the lost files. It will guide you through all the steps of identification and recuperation.

Extundelete

Extundelete is a program that allows you to recover deleted data from an ext3 or ext4 disk in almost all Linux versions and not just Ubuntu.  Both ext3 and ext4 disk storage are by far the most frequent default file systems.

How To Recover Deleted Files In Ubuntu with Extundelete

This tool attempts to retrieve an item that has been erased from a disk using information saved in the partition’s journal. It is a utility that allows you to recover files from an unmounted disk and move them to a different partition.

Extundelete will recover whatever files it finds to the “RECOVERED FILES” subfolder of the root folder. To use the application, execute “extundelete —help” to view the different choices offered and follow the steps as it goes.

TestDisk

TestDisk is one of the most popular and practical tools to recover deleted files in Ubuntu. TestDisk can not only retrieve the data, but it can also restore broken partitions and manage faulty boot regions, which is helpful if your disk structure has been severely damaged.

If you’re using Linux OS, then Check Out this article: How To Recover Deleted Files In Linux Using RM?

How To Recover Deleted Files Using Testdisk?

Well, as we mentioned before, TestDisk is probably the best tool to recover deleted files in Ubuntu, and in this section, we will discuss a step-by=step guide to recovering lost data in Ubuntu using TestDisk.

Step 1: Installing the Tool

Launch the Console, the Ubuntu command prompt, by searching for it in the platform and application launcher or using the Ctrl+alt+T shortcut. Then, as a sudo user, run the following command to install the TestDisk utility. “Sudo apt-get install testdisk.” Follow the picture below for better reference.

installing Testdisk To Recover Deleted Files

After entering the sudo password, the program will be installed on your machine.

Step 2: Run TestDisk

Again go to the terminal and use the following code to run the program.

“testdisk”

You’ll see the details about utility in the output. You’ll be able to generate a testdisk.log file as well. Later on, this file will contain helpful information concerning how and where your lost file was discovered, identified, and restarted.

Step 3: Selecting the Drive

You should be able to view your drive at this point. Then you may move on to the last stages. But let’s pretend you aren’t, and you have something like a multi-boot computer. Ownerships can become hazy in this circumstance, and Testdisk will require your permission to open them. You’ll see something similar to this:

Selecting the Drive

Using the right or left arrow keys, choose Proceed, then press Enter. In order to accomplish effective file recovery, the suitable disk capacity must be recognized.

Step 5: Advanced option

This time, Testdisk shows you all of your hard disks. To access the drive in question, use the arrow keys to go to it and then press enter. Testdisk has chosen the proper option once more.

Advanced option

Testdisk’s ability to recover deleted files is only one of its many capabilities; the program has a lot more to offer. You can choose any of those characteristics from the options shown in the above screenshot.

Step 6: Where you lost the file and browsing directory

The selected drive can have many partitions, and the next page allows you to pick the appropriate one. Testdisk will do a file scan and display a list of deleted files. Go through the files and find the file you want to recover.

Where you lost the file and browsing directory

Step 7: Restoring the deleted file

You must have discovered your missing file in the list by now. Copy the specified file with the C option. This file will be restored to the place that you choose later. Because copying and pasting the file to your selected place is just a simple UI function, you may choose any available location. Click the c button once you’ve decided where you wish to restore the file. This will bring your file back to its original place. If the process is successful, it should look like the screenshot below.

Restoring the deleted file

Conclusion

It can be quite irritating when you lose important files on your computer. However, most of the time, data is lost due to unwanted reasons. But, if you are an Ubuntu user, you can quickly recover deleted files in Ubuntu.

So, if you have been looking at how to recover deleted files in Ubuntu, our guide has already provided you with a list of tools that can be used for this. So, make sure to read this article fully and follow the tool which you feel most comfortable with.

Leave a Comment