When we covered absolute and relative path names , we used the cd command to c hange d irectory. You can be at any point in the file system hierarchy and use cd to change to the desired directory, provided that you have the necessary permissions to change to that directory. We can change a directory using an absolute path name , as shown in the following example: $ cd /home/denise/.netscape-cache Regardless of your current location in the file system hierarchy, this changes you to the directory /home/denise/.netscape-cache . If, however, your current location in the file system hierarchy is /home/denise , then you could use a relative pathname to change to .netscape-cache , as shown in the following example: $ cd .netscape-cache In order to change directory to a place in the file system relative to your current location, you need a way to determine your current location. The pwd command, for p resent w orking d irectory, can do this for you. Going back to the previous example in which we changed directories using the relative path, we could have first issued the pwd command to see that our location was /home/denise , as shown in the following example: $ pwd /home/denise $ cd .netscape-cache $ pwd $ /home/denise/.netscape-cache $ pwd takes some of the mystery out of determining your current directory. Let's now take a look at moving up a level in the directory tree using two dots: $ pwd /home/denise/.netscape-cache $ cd .. $ pwd /home/denise $ The two-dot notation moves you to the parent directory of your current directory. To return to your home directory, you could issue the cd command with no arguments, as shown in the following example: $ pwd /tmp $ cd $ pwd /home/denise $ This shows that no matter what your current location in the file system hierarchy, you can always get back quickly to your home directory. I don't get into shell parameters for some time, but there is a shell parameter that defines your home location, as shown in the following example: $ pwd /tmp $ cd $HOME $ pwd /home/denise $ Using the pwd and cd commands, you can always obtain your current directory and change to any directory. cd - Change to a new current directory.
pwd - Present Working Directory, so you know your current location.
|