Learn

Directories give a hierarchy to files and therefore learning commands for their manipulation is important as well:

  • New empty directories can be created using the mkdir command. This can also create directories within existing directories, called sub-directories.
  • Again, the contents of a directory can be listed using the ls command.
  • A directory can be deleted using the rm command with the -r recursive flag to also delete any files it may contain.

Instructions

1.

Using the command line, create a new directory called dinner using the command mkdir dinner.

Verify that this new directory has been created using the command ls to list all the files in the current directory.

2.

Create 2 more directories within the dinner folder using the command:

mkdir dinner/entree dinner/dessert

Verify the beginnings of this hierarchical tree structure using the ls -R command.

3.

Create a variety of files within these new folders using the command:

touch dinner/entree/turkey dinner/entree/fish dinner/dessert/cake dinner/dessert/pudding

Verify the full hierarchical tree structure using the ls -R command.

4.

Delete the dinner directory using the command rm -r dinner.

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?