You are here:About>Computing & Technology>Focus on Linux> Linux Documentation> Introduction to Linux> Introduction to Linux - 3.2.2. Absolute and relative paths
About.comFocus on Linux
Newsletters & RSSEmail to a friendSubmit to Digg

Introduction to Linux

From Machtelt Garrels

3.2.2. Absolute and relative paths

A path, which is the way you need to follow in the tree structure to reach a given file, can be described as starting from the trunk of the tree (the / or root directory). In that case, the path starts with a slash and is called an absolute path, since there can be no mistake: only one file on the system can comply.

In the other case, the path doesn't start with a slash and confusion is possible between ~/bin/wc (in the user's home directory) and bin/wc in /usr , from the previous example. Paths that don't start with a slash are always relative.

In relative paths we also use the . and .. indications for the current and the parent directory. A couple of practical examples:

  • When you want to compile source code, the installation documentation often instructs you to run the command ./configure , which runs the configure program located in the current directory (that came with the new code), as opposed to running another configure program elsewhere on the system.

  • In HTML files, relative paths are often used to make a set of pages easily movable to another place:


       

    <img alt="Garden with trees" src="../images/garden.jpg">

  • Notice the difference one more time:


       

    theo:~> ls /mp3
    ls: /mp3: No such file or directory
    theo:~>ls mp3/
    oriental/ pop/ sixties/

* License

* Introduction to Linux Index

 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.