rm (delete files)

Deletes (removes) one or more files.

Format:    rm filelist
Examples:  rm file1 file2

To remove files, you must have write permissions to the directory where the file is located, but not on the file itself.

OptWhat It DoesExamples
-dRemove directories, even if not empty (only available to a privileged user)rm -d /home/janet/dir2
-fRemove write-protected files without queryingrm -f file26.txt
-IPrompt before deletingrm -I test*.txt
-rFor a directory, remove all the files in the directory and subdirectoriesrm -r /home/janet/di 3
-vDisplay name before deletingrm -r report*

Get Spring Into Linux® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.