File Operations

rm

Remove files or directories permanently from the filesystem.

Synopsis

syntax
rm [OPTION]... FILE...

Examples

Remove a single file
rm file.txt
Force remove a directory tree
rm -rf /tmp/build/
Remove backup files interactively with verbose output
rm -iv *.bak
Remove a file whose name starts with a dash
rm -f -- -weirdname

Common options

FlagDescription
-r, -RRemove directories and their contents recursively
-fForce removal without prompting
-iPrompt before each removal
-vVerbose — print each removed file
-dRemove empty directories

About rm

The `rm` command remove files or directories permanently from the filesystem. File operation commands are essential for navigating and managing the Linux filesystem.

They form the backbone of everyday system administration and development workflows. Mastering these commands enables you to efficiently create, move, copy, and organize files and directories from the terminal, which is often faster and more scriptable than graphical alternatives.

The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man rm`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Operations Commands

Other commands in the File Operations category

Related tools