User Tools

Site Tools


directories

This is an old revision of the document!


Directories


Getting around on the computer

In this exercise, we will explore moving between directories.

Useful UNIX commands for the exercises below (see unix_commands.pdf for a more complete list):

  • To create a new directory use mkdir.
  • To change directories use cd.
  • To move to your home directory just type cd
  • To move up one directory use cd ..
  • To change into any directory from anywhere use cd /absolute path to directory.
  • To move up one directory and down to another directory use cd ../dir.
  • To access content within another directory provide the path to that directory. For example, ls /absolute path to directory.
  • To go to the beginning of a line in the shell, use ctrl+a.
  • To go to the end of a line in the shell, use ctrl+e.
  • To delete text preceeding cursor in the shell, use ctrl+u.
  • To scroll back or forth in the command history use the up and down arrow keys.
  • To autofill text, use tab. This is highly recommended in order to minimize typos.

★ Interactive Exercise

1. Open a shell or terminal window.

2. Create a new directory called FortCollins.

$ mkdir FortCollins

3. Change into FortCollins using cd:

$ cd FortCollins

4. Confirm that you are in FortCollins using pwd:

$ pwd

5. Within FortCollins create a new directory called Likes:

$ mkdir Likes

6. Change into Likes:

$ cd Likes

7. Create a file called food.txt that contains a list of your favorite places to eat in Fort Collins:

$ echo favorite place to eat >food.txt
$ echo another favorite place to eat >food.txt
$ echo another favorite place to eat >food.txt

8. Change into your home directory:

$ cd

9. List the contents of food.txt from your home directory:

$ ls /path to Likes

10. Change into the Likes directory:

$ cd /path to Likes

11. Move up one directory:

$ cd ..

12. Create a new directory called Dislikes:

$ mkdir Dislikes

13. Change into Dislikes:

$ cd Dislikes

14. Create a file called food.txt that contains at least one of your least favorite places to eat in Fort Collins:

$ echo least favorite place to each >>food.txt

15. Using only one command change into the Likes directory:

$ cd ../Likes


★ Independent Exercise

During the exercise, practice using ctrl+a to go the beginning of a line, ctrl+e to go the end of a line, and ctrl+u to delete text. Examine the contents of the directory you make from both the command line and the Finder GUI.

1. Change into your home directory and make a new directory called One.

2. Change into One.

3. Create two new directories called A and B.

4. Change into B.

5. Using only one command, change into A.

6. Change into your home directory.

7. Using only one command, change into B.

If you have extra time, get lost in Terminus.


directories.1535646917.txt.gz · Last modified: 2018/08/30 10:35 by dokuroot