How to recover a deleted file on Ubuntu?

Who I am
Aina Prat
Author and references

An error came quickly, even on a system as simple as Ubuntu. Whether you have lost a photo, a document or even an archive, there is an effective solution for recover deleted file on ubuntu : Foremost. In this tutorial, we will see how to install and use this handy little software.

To avoid any unfortunate loss of your important files, we recommend that you create regular backups. If you don't know how to do it, don't hesitate to read our tutorial “How to create a restore point on Ubuntu?”.

Recover Deleted File on Ubuntu with Foremost

  1. Open a terminal from the application launcher.

  2. Enter the command sudo apt install foremost to install the Foremost utility.

  3. Enter your password then validate with the key Starter.

  4. To determine which files can be recovered, enter the command sudo foremost -w -i / dev / sda1 -o / Recup. The utility will scan your hard drive for all deleted files and send its report to a file placed in the Recup folder.

  5. Here is an example of the file generated by the previous command. There is a lot to recover!

  6. Here we will try to find all the images in png format deleted by mistake from the PC. To do this, simply enter the command sudo foremost -t png -i /dev/sda1 -o /RecupImages then validate with Starter.

  7. After a little while, all the recovered images will be visible in the folder RecupImages created at the root of the disk.

  8. Foremost does more than just find images. To learn more about the possibilities of this utility, just use the command man foremost in a terminal.

In case of accidental deletion, do not hesitate to use Foremost as soon as possible. The longer you delay, the more likely you are to permanently lose your files!

To download :
Find other tutorials on Ubuntu:
  • How to Format a USB Drive or Hard Drive on Ubuntu?
  • Essential Ubuntu Keyboard Shortcuts
  • The essential command lines to know on Ubuntu
  • How to change a QWERTY keyboard to AZERTY on Ubuntu?
  • How to create a restore point on Ubuntu?
add a comment of How to recover a deleted file on Ubuntu?
Comment sent successfully! We will review it in the next few hours.