Lesson 3 – Navigating the Linux Filesystem

The cd Command

The most important command for moving around in the Linux environment is the cd (“change directory”) command.

    >cd directoryname

As always, you can find out more information about the cd command by reading the man pages:

    >man cd

To return to your UNIX home directory, use the “~” (tilde):

    >cd ~

Or to go to someone else’s home directory add his/her username after the “~” (tilde) sign:

    >cd ~username

Note: You must have execute permission on a directory in order to cd to it (then you will need read permission in order to list (ls) the files in that directory).

Also note: The “/” (forward slash) is used in the path name to separate directory names. So, you do not have to change one directory at a time:

    >cd directoryname/subdirectoryname/anotherdir

In the case above, the directory, called “directoryname“, is in the directory where you are currently located. If you need to get outside of your current directory, there are a few ways to do this:

  • >cd ..

    In the example above, you are going up one level.

  • >cd ../adir/bdir

    In the example above, you are going up one level then over to the directory, “adir“, and the sub-directory, “bdir“.

  • >cd /adir/bdir

    Note the initial “/” (forward slash). In the example above, you are going to the root (top level) of the filesystem and then going to the directory, “adir“, and then the sub-directory, “bdir“.

Read the man pages for more information:

    >man cd

The pwd Command

To find out what directory you are currently in, use the pwd (“print working directory”) command:

    >pwd

Continue to Lesson 4 – Viewing/Searching for Files
Return to index of lessons.

Last revised May 9, 2003.