The rm command
remove files or directories 10 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.
Options in the examples
-r, -R, --recursive- remove directories and their contents recursively
-f, --force- ignore nonexistent files and arguments, never prompt
-i- prompt before every removal
-I- prompt once before removing more than three files, or when removing recursively; less intrusive than -i, while still giving protection…
-v, --verbose- explain what is being done
Examples
rm file.txt
rm file1.txt file2.txt file3.txt
rm *.txtDelete all .txt files
rm -r directory/Delete directory and all contents
rm -i file.txtInteractive: confirm each deletion
rm -I *.txtPrompt once before deleting 3+ files
rm -v file.txtVerbose: show what's being deleted
rm -rf /NEVER run this — deletes everything!
rm ~/.bash_historyDelete history file
sudo rm oldfile.logDelete if it's safe to lose