Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Recover Deleted Files on Linux

Understand Recover Files, how it works, key uses, common issues, and practical considerations. Use this clear guide to make informed decisions.

Table of Contents

This practical guide explains how to recover deleted files on linux with clear steps and useful context. It also covers common requirements, potential problems, and the details that can help you get better results.

Recover Deleted Files on Linux with Testdisk

TestDisk is an open source data recovery program that can effectively recover files or partitions that have been permanently deleted. It is packed with useful features and offers an easy to use interface. You can install TestDisk on Linux with the following commands:

# Ubuntu and Debian sudo apt install testdisk # RHEL and CentOS sudo yum install epel-release sudo yum install testdisk # Arch Linux sudo pacman -S testdisk

Once installed, start TestDisk by opening Terminal and entering the command testdisk.

sudo testdisk

Use the arrow keys on your keyboard to navigate and press Enter to select options. The first available option is to create a log file. Go ahead and create a file.

Recover Deleted Files on Linux with Testdisk - Recover Files

Man hinh sau se hien thi danh sach cac phuong tien luu tru ?uoc ket noi voi he thong cua ban. Chon thiet bi co chua cac file ?a xoa. Vi du ?ang su dung phuong tien /dev/sdb cho huong dan nay. Chon phuong tien phu hop cua ban va nhan Proceed.

Recover Deleted Files on Linux with Testdisk - Recover Files

Man hinh tiep theo se nhac ban chon loai phan vung cho o ?ia. Chon mot loai phan vung chinh xac cho o ?ia cua ban. Luu y rang TestDisk se co gang tu phat hien ?ung loai. Vi vay, neu ban khong chac chan, hay chuyen sang loai phan vung ?uoc TestDisk phat hien.

Recover Deleted Files on Linux with Testdisk - Recover Files

Ban se thay mot so tuy chon co san tren man hinh sau. Tuy chon analyze rat huu ich ?e khoi phuc cac phan vung bi mat. Tuy nhien, vi du se su dung tuy chon Advanced ?e khoi phuc cac file ?a xoa.

Recover Deleted Files on Linux with Testdisk - Recover Files

Tiep theo, ban se thay danh sach tat ca cac phan vung co tren thiet bi ?a chon cua minh. Chon phan vung chua du lieu ?a xoa cua ban va chon Undelete tu menu duoi cung.

Recover Deleted Files on Linux with Testdisk - Recover Files

TestDisk will scan MFT entries for deleted files on this partition and list them here. The example is looking for the picture.jpg file displayed on this screen.

Recover Deleted Files on Linux with Testdisk - Recover Files

You can select/deselect specific files using: and all files using a. After selecting the files to recover, press C to copy them.

Recover Deleted Files on Linux with Testdisk - Recover Files

You will be prompted to choose a restore destination. Navigate there and press C to save the file.

Recover Deleted Files on Linux with Testdisk - Recover Files

Recover Deleted Files on Linux with Photorec

PhotoRec is another powerful data recovery program created by the developers of TestDisk. It was developed to recover deleted photos on Linux but has now evolved into a full-fledged program that can use PhotoRec to recover all types of deleted files.

The difference between TestDisk and PhotoRec is that PhotoRec can access files even from drives that have been damaged beyond repair. It uses file signatures to detect deleted files, which makes the tool extremely powerful. However, files accessed via PhotoRec do not retain their original filenames.

You can install PhotoRec on different Linux distributions using the same commands used to install TestDisk. So if you already have TestDisk installed, you don't need to reinstall PhotoRec. If you don't have TestDisk installed before, see above and install testdisk package.

sudo photorec

This command will start PhotoRec and take you to the Start menu. The layout is similar to TestDisk and so is the navigation. You will be prompted to select the drive media. Select the correct one you want and click Proceed.

Recover Deleted Files on Linux with Photorec - Recover Files

Then you will need to select the source partition. Select the appropriate partition and select File Opt from the bottom menu.

Recover Deleted Files on Linux with Photorec - Recover Files

Here, you can specify the type of deleted files. PhotoRec selects all file types by default. You can disable all using s and select a specific type using x. The example is choosing jpg to restore image files.

Recover Deleted Files on Linux with Photorec - Recover Files

Now, go back with q and select the Search option to start recovering files on Linux.

Recover Deleted Files on Linux with Photorec - Recover Files

Then you will need to select the file system type. Select Other if the source partition is not ext3/ext4.

Recover Deleted Files on Linux with Photorec - Recover Files

At this step, you must specify whether to search the selected file types in the entire partition or only in the free space. The example is choosing the Free Space option for faster searching.

Recover Deleted Files on Linux with Photorec - Recover Files

The next step asks the user to select the destination folder. Make sure not to save the file on the same partition that you are scanning. Navigate to the desired location using the arrow keys and press C to save.

Recover Deleted Files on Linux with Photorec - Recover Files

PhotoRec will now scan for empty sectors and save the recovered files to the selected destination. It will save the recovered files in a folder named recup_dir.

Recover Deleted Files on Linux with Photorec - Recover Files

Recover Deleted Files with Foremost on Linux

Foremost is a free data recovery tool for Linux. It comes with a simple CLI interface. Although the software is not as interactive as TestDisk or PhotoRec, it still proves to be useful in certain situations.

Thanks to the plethora of high-quality data recovery programs, recovering deleted files is quite easy on Linux. You can choose any of the above tools based on the type of deleted files and your system partition configuration. However, the article recommends TestDisk and PhotoRec because they provide simple and clear interactive prompts.

Since data recovery can be a nightmare for many people, you should always store backups on an external device. It will help to get back deleted data with just a few clicks.

Conclusion

Understanding Recover Files makes it easier to compare options, avoid common mistakes, and apply the information in this guide more effectively. Review the relevant requirements before making changes or choosing a solution.

FAQ

How do you recover deleted files on linux?

Follow the steps in this guide in order, confirm the required settings or tools, and verify the result before making additional changes.

Is it safe to recover deleted files on linux?

It is generally safe when you follow the recommended instructions, use trusted tools, and avoid changing settings you do not understand.

What should you do if the process does not work?

Recheck the requirements, restart the device or application when appropriate, and review each step for missed settings or compatibility issues.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.