Digital Communication


Digital Communication

Linux rm command: delete files and directories


The rm command for Linux is used to completely delete files and directories, without using the clipboard. We therefore advise you to use this command with caution and to refine it by using options.

Linux rm command: what is it?

You wish delete entire files or directories permanently ? The Linux rm command is the ideal solution. The term “rm” is a contraction of the English verb “remove”, which means “to remove”. If you work with the terminal in one or more Linux distributions, such as Ubuntu, you are likely to find yourself frequently called upon to use the rm command. This command is the fastest way to delete files and directories. It allows you to clean your folders and eliminate any superfluous data from your directories. However, it should be noted that the data thus selected does not even pass through the “Trash” box, as is the case with other operating systems. If you run the Linux rm command, be aware that you will not be able to recover the selected data. We therefore advise you to exercise the utmost caution.

How does the rm command work?

The operation of the rm command is relatively simple. If you want to delete files or directories in their entirety, you just need to give the system the corresponding instruction. To do this, you must specify the terminal in which the data that you no longer need is located before deleting the latter. This command has two important particularities: the definitive nature of the deletion that it allows, and the management of files. Indeed, the rm command also allows to delete directories, these containing other data. The deletion then applies to all the documents in the same folder.

What does the rm command syntax look like?

The Linux rm command syntax is as follows:

$ rm [Option] [Fichier ou Dossier]


“rm” is the name of the command to run. The file or folder to be deleted is indicated at the end of the code snippet; if you want to delete several files, you can write the corresponding names one after another. Various options also allow you to fine-tune this command.

What are the rm command options?

Many options are available for the Linux rm command. Below are the most important of them.

  • -f or –force: it allows to impose the deletion, without any request; in general, we do not recommend that you use this option because of the high risk of error associated with it.
  • -i or –interactive: it allows to request an additional confirmation before each deletion process; the file in question is only deleted after this confirmation. This helps prevent accidental deletion.
  • -r, -R or –recursive: it allows the deletion to be performed recursively. So, in addition to the directory itself, all subfolders and files are also deleted. The risk is also significant with such an option.
  • -v or –verbose: it is used to indicate the action being performed by the command.

Linux rm command: some examples

Finally, let us show you some examples of how the Linux rm command works in practice.

$ rm exempledefichier.txt


This command deletes the file examplefile.txt.

$ rm exempledefichier.txt deuxieme_exempledefichier.txt troisieme_exempledefichier.txt


This command deletes the three files whose names have been entered.

$ rm -r /Exemplededossier


This command deletes the folder Examplefileas well as all of its files and subdirectories.

$ rm -ri /Exemplededossier


This command also deletes the folder Examplefile, as well as all of its files and subdirectories. However, you must confirm the deletion of the affected files before such an action is performed.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact