16.7. Exercises: TerminalΒΆ

Launch the terminal application and perform the following tasks:

  1. Using your terminal, navigate to your Home directory using cd ~.

  2. Use ls to view the contents of your Home directory.

  3. Use cd to move into your Desktop directory.

  4. In the terminal, use mkdir to create a folder on the Desktop called my_first_directory. Look on your Desktop. Do you see it?

  5. Use cd my_first_directory to move inside that directory.

  6. pwd to check your location.

  7. Create a file called my_first_file.txt with touch my_first_file.txt.

  8. Use ls to prove that my_first_file.txt appears in my_first_directory. (Bonus: Open the file in a text editor and write yourself a message!)

  9. Make a copy of my_first_file.txt onto the Desktop with cp my_first_file.txt ../my_first_copy.txt.

    Tip

    Notice the different file name in the command! This keeps us from making two files that have the same name.

  10. Move up to your Desktop directory with cd ...

  11. Use ls to verify that my_first_copy.txt appears on your Desktop. (Bonus: Open it up. Is it the same as your first file?)

  12. Move your copied file into my_first_directory with mv my_first_copy.txt my_first_directory/.

  13. Use ls to see that the copied file is no longer on your Desktop.

  14. Type cd my_first_directory, followed by ls to confirm that my_first_copy.txt has been moved into that folder.

  15. Type rm my_first_copy.txt followed by ls. Congratulations, you just deleted the file!

  16. cd .. to get back to your Desktop.

  17. Type rm -r my_first_directory/. Use ls and a visual check to verify that you removed the directory.