Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Relative and Absolute Paths

July 19, 1998

The first thing we need to understand is how the file system is addressed. That is, how do you know where within the file system you are or where your file is located?

UNIX has an address system based upon file paths. A file path specifies the route that you need to take in order to find a file within the file tree much like a map directs you from one location to another.

In UNIX, all paths start from the "root" directory. The root directory is specified by a single slash "/" character. From there, steps along the path are separated by successive slash characters.

Thus, the path "/usr/selena/public_html/index.html" specifies a file called "index.html" which is located in the "public_html" directory, which is a sub-directory of "selena", which is a sub-directory of "usr", which is itself a sub-directory of "root"!

This type of path is called an absolute path because it references a file or directory absolutely from the root.

However, paths can also be relative to your current location within the file system. To specify a relative path, you do not specify the path from "root" by not including the initial slash character.

For example, if we were currently located in the "selena" sub-directory, we could refer to the file "index.html" using the path "public_html/index.html". Notice that since we do not include the initial "/" UNIX will assume that the specified path is relative to your current location which is "/usr/selena".

Two final important path tools are the ".." and "." notations. In short, ".." stands for the directory directly above the present directory and the "." refers to the present directory.

Thus, if we were in the "public_html" directory from our example above, "./.." would stand for the "selena" directory and "./../.." would stand for the "usr" directory. If this is all a bit confusing now don't worry, you can learn this by actually doing it on a UNIX machine. It will all make more sense when you can do it yourself.

Additional Resources:

The File System
Introduction to UNIX for Web Developers | Table of Contents
The "pwd" Command


Up to => Home / Internet / UNIX / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers