Beginner Package: coreutils

rm

Remove files and directories.

Syntax

rm [options] file

Description

rm deletes files, and with -r deletes directories and their contents recursively. There is no undelete on most Linux filesystems, so rm is used carefully, especially with wildcards.

Examples

rm file.txt
Delete a single file
rm -r old-project/
Recursively delete a directory and everything in it
rm -i *.log
Delete matching files, prompting for confirmation on each
There is no Recycle Bin โ€” always double-check the path and pattern before running rm -r.

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux