On-line Tutorials College Credit Continuing Ed. Certifications

Home > On-line Tutorials > UNIX Directory Structure

 

UNIX Directory Structure

The key to setting up scripts is understanding the UNIX directory structure. By that I mean the naming convention used to "point to" files on your ISP's server. Because UNIX is completely not windows based (ie, you can only do things by typing text commands, not by using the mouse), you have to be able to name each file on the computer.

Directories

On Windows, you think of things in terms of "folders". You might create a folder called "MyWebsite" somewhere on your C: drive and that folder might contain a file called "default.htm". So, you could say that the full path to your file is "C:\MyWebsite\default.htm". That is the type of convention used to locate UNIX files. On UNIX they are referred to as "directories" instead of "folders".

File Naming

There are a few fundamental differences between the file naming conventions on Windows and on UNIX:

  • UNIX is _case_sensitive_ ... that means there is a difference between Default.htm and default.htm and default.HTM (they would be three distinct files on a UNIX server)

  • UNIX uses the forward slash (/) instead of the back slash (\). You can see that convention in the URLs given in the related web links below.

  • UNIX does not limit the number of letters in a filename. That's why you'll often see HTML files ending in .html on UNIX (ex. index.html) whereas on Windows they limit it to .htm

Path Names

Just like how on PCs the "root" of all file folders is your C: drive, UNIX also has a "root directory". The notation for the UNIX root directory is a single /. All directories and files on the server have an absolute path based from this root directory. For example, if there is a directory under the root directory called "MyFiles", and in that directory is a file called "index.html". The absolute path to that file would be "/MyFiles/index.html".

There can be many, many layers of directories between the root directory and a file on the server. For example, the absolute path to the main HTML page for enscript.com is: /usr/home/ashley/www/index.html

Relative Paths

If you are "in" a given directory, you can specify a relative path for a file by leaving of the portion of the path that goes up to the current directory. You can also use the symbol ".." to indicate the parent directory.

When I say "in" a directory, I mean either of these:

  1. you are logged in via telnet and through "change directory" commands have moved into the directory
  2. you are editing a file in a given directory and need to reference other files (ex, an image link)
For an example, consider the directory structure diagrammed below:

Examples of absolute paths:

    /home/ashley/dir1/fileD
    /home/ashley/fileA
    /home/ashley/dir2/fileE
Now, if you are editing a fileB and need to "point" to other files, here are the shortcuts you can use:
    fileA
    fileC
    dir1/fileD
    dir2/fileE
If you are editing fileD, you can use these shortcuts:
    ../fileA
    ../dir2/fileE

Related tutorials

UNIX directory structure
UNIX file permissions
Basic UNIX commands
Useful UNIX tasks
Using telnet

 

 

 

About iTeachU
Programs Offerred
Library
Book Store
Other Resources

Course Access

 

 

 

Home > On-line Tutorials > UNIX Directory Structure

On-line Tutorials College Credit Continuing Ed. Certifications

 

info@iteachu.com

© Copyright 2001-2002 iTeachU All Rights Reserved