5.3 Navigating the File System
5.3.3 Changing directories using the cd command
Files you need to access are often stored in subdirectories below your home directory. Because of the way in which a UNIX file system is set up, it is often desirable to change directory locations. The cd (change directory) command is used to change to a new current directory. This command, like all UNIX commands, accepts both absolute and relative pathnames.
Command Format:  
cd [directory_name]

You can move around in the directory hierarchy using the cd command along with an absolute or relative pathname as shown in the examples in Figure . In the first example, we use the cd command with an absolute pathname. It does not make any difference where you currently are in the directory hierarchy because you are specifying to start at the root (/) directory. The second example uses the cd command with a relative pathname. It assumes you are currently in the /home directory which you changed to in Example 1. If you were not in the /home directory, you would receive an error stating that the directory that you were trying to change to does not exist. The third example shows a feature of the cd command which allows you to quickly return to your home directory (ex: /home/user2). Entering the cd command by itself (without specifying a pathname) automatically places you in your home directory.

Navigation shortcuts with
cd 
Pathname abbreviations are a form of shorthand when moving between or referring to directories. They can save keystrokes when used with the
cd command. The shortcuts we will cover include the dot (.) which is basically a period, the dot/dot (..) or two periods, and the tilde (~), the wavy symbol usually found above the Tab key on most keyboards, representing your home directory. Directories always contain a link to their parent directory which is designated by the dot/dot (..) and a link to themselves, which is the dot (.). The ls -a (list files -all) command, which will be covered in the next section, will show a dot (.) and a dot/dot (..) even if the directory is empty. These shortcuts can be useful when changing directories using the cd command and others.

You can use pathname abbreviations or shortcuts with the cd command to move around the file structure. Figure shows some examples for using the shortcuts with the cd command assuming your current working directory is /home/user2/dir1.

Note: All directory, subdirectory and file names are case-sensitive.

Interactive Media Activity (Flash, 93 kB)
  Using the pwd and cd commands

This activity will demonstrate your ability to use the pwd and cd commands. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and complete the activity. Be sure to use lower case command names and forward slashes.

Lab Activity (Adobe Acrobat Reader, 32 kB)
  Navigating the File System

In this lab you will work with the UNIX file system or directory tree, which has been set up for the class. You will learn how to determine your current location in the directory tree and how to change from one directory to another.