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.
Note that you can access the layout of the filesystem here.
Instructions
For this exercise, we need to start in the comedy/slapstick/
directory. Use pwd
to check where you are. If you aren’t in the comedy/slapstick
directory, you can use the command:
cd /home/ccuser/workspace/movies-rpi/comedy/slapstick
Now that you are in the correct directory, 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.