52 Chapter 4 – A Beginner’s Guide to the Server
Introduction to Unix
Web Design in a Nutshell, eMatter Edition
Relative pathnames
A relative pathname points to a file or directory relative to your current working
directory. When building a web site on a single server, relative pathnames are
commonly used within URLs to refer to files in other directories on the server.
Unless you specify an absolute name (starting with a slash) the shell assumes you
are using a relative pathname. Starting in your current location (your working
directory), you can trace your way up and down the directory hierarchy. This is
best explained with an example.
If I am currently working in the directoryjenand I want to refer to the fileart.html,
the relative pathname would bepers/art.htmlbecause the fileart.htmlis in the
directory pers, which is in the current directory, jen. This is illustrated in
Figure 4-4.
Figure 4-3: Visual representation of the path /users/jen/pers
Figure 4-4: Visual representation of the path pers/art.html relative to the jen
directory
/ (root)
bin etc users tmp lib
jen richard
work pers
art.html
work
/
users
jen
pers
/users/jen/pers
/ (root)
bin etc users tmp lib
jen richard
work pers
art.html
work
jen
pers
pers/art.html
art.html
current directory