Absolute and Relative Path Names


We have already covered two topics that can serve as the basis for a discussion of absolute and relative path names: some important directories on the system and user login. If you take a look at the user denise and the way some of her files can be organized, we can get to the bottom of relative and absolute path names quickly.

The UNIX file system covered in Chapter 2 showed a hierarchy. In this hierarchy, there was the root ( /) directory at the top, and files and directories were below root. The two means by which you can traverse this hierarchy to get to a "lower" point are with absolute path names and relative path names. Let's take a closer look at the files and directories that denise may have in her user area.

First of all we'll assume that denise has many files. This activity is one of the things users do - create files. In addition, your system administrator has provided several default files for purposes such as defining your user environment after login (we'll get into this in a lot more detail in upcoming chapters). denise probably has many files under her user area, and subdirectories as well. Her user area may look something like that shown in Figure 21-3:

Figure 21-3. Home Directory for denise

graphics/21fig03.gif

Most users will have their home directory under /home (and who said UNIX doesn't make any sense?). If you want to get to a subdirectory of denise using an absolute path name , you traverse the hierarchy using the complete path. To get to the directory .netscape-cache under denise , you could view the absolute path as shown in Figure 21-4:

Figure 21-4. Absolute Path

graphics/21fig04.gif

You are progressing from root ( / ), to home , to denise , and finally to the directory .netscape-cache . The change directory ( cd ) command you issue looks like the following:

 $  cd /home/denise/.netscape-cache  

This is an absolute path because it starts at root and progresses through the hierarchy. No matter what directory you are currently working in, even if it is .netscape-cache , you could use the absolute path name. In many cases, however, you may not need to issue an absolute path name. You may be so close to the file or directory you wish to access that the absolute path would be a waste of time for you. If, for instance, you are already in /home/denise , then you could change to .netscape-cache using a relative path name easily:

 $  cd .netscape-cache  

The relative path name is shorter because you don't begin with a slash ( / ) that brings you back up to the top of the hierarchy to work your way down. Instead, you are starting at some point in the file system hierarchy, such as /home/denise , and entering a path relative to that directory, such as .netscape-cache .



HP-UX 11i Systems Administration Handbook and Toolkit
HP-UX 11i Systems Administration Handbook and Toolkit (2nd Edition)
ISBN: 0131018833
EAN: 2147483647
Year: 2003
Pages: 301

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net