How to use Foremost to recover deleted files in Linux

The rm command is one of the most dangerous commands for Linux users. If you delete the wrong file or directory, you can make your entire operating system unusable. Recovering lost files is not easy, but it is also not possible. Foremost is designed to diagnose your hard drive in order to recover any files you have deleted. This article provides a tutorial on how to use the Foremost tool.

What is foremost?

Developed by US federal agencies, Foremost (link: http://foremost.sourceforge.net/ ) is open source software. Instead of trying to retrieve files from the hard drive's file system, Foremost tries to directly recreate those files.

How to use Foremost to recover deleted files in Linux Picture 1

Most operating systems do not delete files completely from the file system. They only delete metadata and leave the data written below. Foremost will then copy and analyze the drive for this information.

Foremost will store information temporarily using memory in your PC. From there, it will look for certain file segments (segments) until it matches other segments, stitching them together (like a jigsaw puzzle).

Foremost supports certain file types. Image files like JPG and GIF, Windows binary files like EXE, document files like DOC and PDF, as well as compressed file formats like ZIP or RAR are all supported.

Install Foremost in Linux

Foremost is available as a package to install in most default Linux repositories. You can install it from the terminal using the package manager used by the Linux distribution.

How to use Foremost to recover deleted files in Linux Picture 2

Debian and Ubuntu-based distributions can install Foremost by opening a terminal and typing the following:

 sudo apt install foremost 

If you are running Arch Linux, you can install Foremost by entering:

 pacman -S foremost 

Fedora users can install Foremost from the terminal by typing:

 dnf install foremost 

How to use Foremost

If you have deleted a file and want to retrieve it, you can use Foremost to search for all files of the same type that were previously deleted.

First, you will need to know your drive partition name in Linux, for example '/ dev / sda1'. If you do not know your partition, enter the following into the terminal:

 df -h 

You will see a list of hard drive partitions listed. Locate the drive you want Foremost to search, listed in 'Filesystem'.

How to use Foremost to recover deleted files in Linux Picture 3

Once you know your hard drive partition, you can use Foremost to search your drive. For example, if you are looking for a deleted PNG file, open a terminal window and type the following:

 foremost -v -t png -i /dev/sda1 -o ~/recovery/ 

Replace '/ dev / sda1' with your hard drive partition. The -t flag allows you to select the file type to search for. The -i flag selects the drive you want to search, while the -o flag lists the directory where any restored files are stored.

How to use Foremost to recover deleted files in Linux Picture 4

You can use a similar procedure for any type of file you want to use. Replace png with your file type. You can search the entire drive or through specific directories.

When Forecast completes the search, all the files it locates will be saved in the output directory you listed under the -o flag . If you have difficulty, you can search through the Forecast's user guide by typing in the terminal:

 man foremost 

Retrieve deleted data in Linux

There is no guarantee that Foremost can recover any data you have lost or deleted. However, this is still one of the best free tools for retrieving data.

Unless you're willing to spend money on a better tool, Foremost is one of the best options available for accessing data in Linux. If Foremost doesn't work in your case, there are other Linux recovery tools available that you can try instead.

Hope you are succesful.

3.8 ★ | 18 Vote

May be interested

  • How to recover, retrieve deleted files in trashHow to recover, retrieve deleted files in trash
    how to recover, retrieve deleted files in trash. in the course of using the computer, you have probably encountered a case of mistakenly deleting data. if you are in that case, don't worry, because when we delete a file in windows, the file
  • Recover deleted files in Exchange Server 2003 (Part I)Recover deleted files in Exchange Server 2003 (Part I)
    today we will introduce the series on recovering deleted files on exchange server 2003. this series is divided into two parts, the first part introduces how to recover data at the mailbox storage level. part two will discuss dry matter
  • How to recover deleted files on iCloud DriveHow to recover deleted files on iCloud Drive
    how to recover deleted files on icloud drive. icloud drive is apple's cloud service that helps us transfer data in apple devices like iphone, ipod, ipad, macboook ... easily. in addition, we can also use icloud drive to create a backup of data
  • How to recover deleted files in Windows 10How to recover deleted files in Windows 10
    you can delete unused files on your computer to increase free space, or for privacy reasons. however, during the cleaning process, you accidentally delete some important files by mistake. so is it possible to recover? here are ways that can help you fix the mistake, even of permanently deleted files.
  • How to recover deleted files on Microsoft TeamsHow to recover deleted files on Microsoft Teams
    in case of accidental deletion of an important file on microsoft teams, how do you get it back? please follow the article below to know how to recover deleted files on microsoft teams
  • Instructions for finding and recovering deleted dataInstructions for finding and recovering deleted data
    what would you do if after deleting a file but realized it was an important file? or is there a file that is suddenly infected by virus and then deleted by antivirus software? undelete 360 ​​is an effective solution that can be used in this case.
  • How to recover deleted photos on Android device?How to recover deleted photos on Android device?
    if you accidentally delete your favorite pictures on your android device, don't worry too much, or blame yourself for doing anything. there are still some solutions for you to choose to restore these deleted images.
  • How to recover files and data deleted by Avast by mistakeHow to recover files and data deleted by Avast by mistake
    how to recover files and data deleted by avast by mistake. avast is not perfect, sometimes the software will delete your data file by mistake. so how to recover, recover files when avast deleted by mistake?
  • Recover accidentally deleted data in USBRecover accidentally deleted data in USB
    when you mistakenly delete data on a usb that is quite important to you, you do not know how to recover those deleted data? softorbits flash drive recovery is a software that helps recover deleted data on usb quickly.
  • How to recover deleted files permanently in the trashHow to recover deleted files permanently in the trash
    sometimes you want to temporarily delete a file or a folder in the trash (recycle bin) but accidentally miss shift + delete or empty recycle bin and so all data is gone completely. however, we can still save deleted data by tips in the article below.