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.
Opt | What It Does | Examples |
---|---|---|
-d | Remove directories, even if not empty (only available to a privileged user) | rm -d /home/janet/dir2 |
-f | Remove write-protected files without querying | rm -f file26.txt |
-I | Prompt before deleting | rm -I test*.txt |
-r | For a directory, remove all the files in the directory and subdirectories | rm -r /home/janet/di 3 |
-v | Display name before deleting | rm -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.