Everybody already had to deal with an accidental file deletion on their computer. Usually, no drama, digging into the trash is enough to restore the file.

Alias rm ( heal… )

Under Linux, command rm is a command of irreversible deletion. In order to minimise the risk of inadvertent file deletion, we are going to force the prompt of the system to confirm any deletion.
This way we are going to rewrite the alias of command rm with argument -i :

Now, command rm is automatically substituted by rm -i, and by this way, you will have a confirmation request at each use of this command.

Foremost ( … prevent )

If, despite the confirmation request, you inadvertently deleted the file, the Foremost tool can help you :

Let’s imagine that you deleted the file /boot/images/file_deleted.jpg, you just need to launch this command :

The Foremost tool will then search for jpg-type files deleted on partition /dev/sda1 matching with folder /boot/images where the deleted file was placed to restore it in the folder /home/folder/restoration.

In the example, we can imagine that directory /boot is on partition /dev/sda1 and directory /home is on partition /dev/sda2.
It is actually important to restore the file in a different target partition from the original one in order to avoid taking the risk of writing on disk sectors previously used by the file to restore.

By using Foremost, you have to notice that :
– This tool is not a guarantee of results and the process will not always allow your files to get successfully restored,
– You have to stop any other activity before launching the process to avoid solliciting your hard disk during the restoration.

Above all, the concept you should embrace is to remain vigilant while using the command rm.

Categories: SystemTutorials

JN Community

Les Ressources, en particulier les tutoriaux, présupposent que l’Utilisateur qui décide de les mettre en œuvre dispose des connaissances, des compétences et de l’expérience nécessaire pour cette mise en œuvre. L’Utilisateur disposant d’une connaissance, compétence et/ou expérience limitée ou insuffisante doit absolument s’abstenir de mettre en œuvre les Ressources par lui-même. Jaguar Network décline toute responsabilité quant aux conséquences dommageables de la mise en œuvre des Ressources, notamment sur les infrastructures informatiques de l’Utilisateur, de ses commettants ou préposés ou de tout tiers. Il est précisé en tant que de besoin que toute intervention de Jaguar Network visant à réparer les dommages causés par la mise en œuvre des Ressources par un Utilisateur ne disposant pas des connaissances, compétences et/ou expériences suffisantes sera facturée et fera l’objet d’un devis préalable et d’un bon de commande aux conditions des contrats Jaguar Network en vigueur.

Related Posts


Shutdown and restart your Linux system

Vote On Linux system, there are a lot of commands to shutdown and reboot your system. This tutorial aims to detail some existing possibilities. Articles similaires


Installation of a web server LEMP (Linux, Nginx, MySQL, PHP)

Vote The installation of a server LEMP Linux + Nginx + MySQL + PHP might be more useful and efficient than an Apache (server LAMP). Articles similaires


Operating load-balancing with HAproxy

Vote HAproxy is a software allowing Load-Balancing between several web servers by allocating requests in an almost transparent way for the user. Articles similaires