next up previous contents index
Next: 3.3.2 Looking at the Up: 3.3 First Steps into Previous: 3.3 First Steps into

3.3.1 Moving around

Now that we can login, and know how to refer to files using pathnames, how can we change our current working directory, to make life easier?

    The command for moving around in the directory structure is cd, short for ``change directory''. You'll notice that many often-used Unix commands are two or three letters. The usage of the cd command is:

cd

where is the name of the directory which you wish to change to.

As we said, when you login, you begin in your home directory. If Larry wanted to move down into the papers subdirectory, he'd use the command

/home/larry# cd papers
/home/larry/papers#

As you can see, Larry's prompt changes to reflect his current working directory (so he knows where he is). Now that he's in the papers directory, he can look at his history final with the command

/home/larry/papers# more history-final

      Now, Larry is stuck in the papers subdirectory. To move back up to the parent directory, use the command

/home/larry/papers# cd ..
/home/larry#

(Note the space between the ``cd'' and the ``..''.) Every directory has an entry named ``..'' which refers to the parent directory. Similarly, every directory has an entry named ``.'' which refers to itself. Therefore, the command

/home/larry/papers# cd .

gets us nowhere.

You can also use absolute pathnames in the cd command. To cd into Karl's home directory, we can use the command

/home/larry/papers# cd /home/karl
/home/karl#

Also, using cd with no argument will return you to your own home directory.

/home/karl# cd
/home/larry#

 



next up previous contents index
Next: 3.3.2 Looking at the Up: 3.3 First Steps into Previous: 3.3 First Steps into



Matt Welsh
mdw@sunsite.unc.edu