Learn

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

1.

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.

2.

Inside the current directory, remove waterboy.txt.

3.

List all files and directories in the working directory. You should see that waterboy.txt has been removed.

4.

Navigate up one directory from comedy/slapstick/ to comedy/.

5.

Remove the slapstick/ directory using rm.

6.

List all files and directories in the working directory. You should see that the slapstick/ directory has been removed.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?