The rm
command deletes files and directories. Here we remove the file unwanted_file.txt from the filesystem.
rm unwanted_file.txt
The -r
is an option that modifies the behavior of the rm
command. The -r
stands for “recursive,” and it’s used to delete a directory and all of its child directories.
rm -r unwanted_directory
Be careful when you use rm
! It deletes files and directories permanently. There isn’t an undelete command, so once you delete a file or directory with rm
, it’s gone.
Instructions
From our current working directory movies/, and with a single command, change directory to comedy/slapstick.
Then, list all files and directories in the working directory.
Inside the current directory, remove waterboy.txt.
List all files and directories in the working directory. You should see that waterboy.txt has been removed.
Navigate up one directory from comedy/slapstick/ to comedy/.
Remove the slapstick/ directory using rm
.
List all files and directories in the working directory. You should see that the slapstick/ directory has been removed.