Exploring rm - Linux Commands

| 3 min read

What isthe rm Command in Linux?

The rm command stands for remove. At its core, rm does what its name suggests: it deletes files or directories from the file system. However, its utility extends far beyond mere deletion; it can manage and clean up your file system efficiently, offering various options to control its behavior.

Basic syntax:

rm [option] [file]

Delete a file:

rm file.txt

Delete more than one file:

rm file1.txt file2.txt

Options

OptionDescription
-i, —interactivePrompts before every removal.
-f, —forceOverrides any existing files at the destination without prompting for confirmation.
-r, —recursiveRemoves directories and their contents recursively.
-d, —dirRemoves empty directories.
-v, —verboseProvides detailed feedback on the actions performed by rm.
—preserve-rootEnsures that the root directory / is not accidentally removed.
—one-file-systemLimits the removal to the current file system, avoiding crossing file system boundaries.

Additional Help

You can explore more by using the commands:

rm --help
# or
man rm

Thank you!

Thank you for your time and for reading this!