Easy Tutorial
❮ Linux Shell Io Redirections Linux Comm Mdu ❯

Linux rm Command

Linux Command Manual

The Linux rm (short for remove) command is used to delete a file or directory.

Syntax

rm [options] name...

Parameters:

Examples

To delete a file, simply use the rm command. To delete a directory, you must use the "-r" option, for example:

# rm test.txt
rm: remove regular file 'test.txt'? y
# rm homework
rm: cannot remove 'homework': Is a directory
# rm -r homework
rm: remove directory 'homework'? y

To delete all files and directories in the current directory, use the following command:

rm -r *

Once a file is deleted using the rm command, it cannot be recovered, so use this command with caution.

Linux Command Manual

❮ Linux Shell Io Redirections Linux Comm Mdu ❯