The file system

The directory separator in Unix is the forwards slash, '/'. The directory structure of any Unix system starts at the root directory, /. It will then be divided into a number of sub-directories. While there are variations between the different implementations of Unix, there are some common themes to the way these sub-directories are divided up and named. Here is an illustrative directory structure, with some brief explanations of what the sub-directories contain:
     |-- bin     - location of commonly used Unix commands (executables) e.g. ping, tar
     |             (Not necessarily in binary - could be Shell scripts)
     |
     |-- boot    - in Linux systems, holds the key boot files (compressed OS image etc.)
     |
     |-- dev     - files for system devices, terminals, disks etc. 
     |
     |-- etc     - important system configuration files, e.g. fstab (file system table)
     |
     |          |-- fred1     - under /home typically go all the home directories of 
     |-- home --|               users of the system.  So /home/sally6 is the home directory
     |          |-- sally6      of the user with id sally6.  sally6's home directory 
     |          |               can also be referred to with ~sally6
     |          |-- ...
     |
     |-- lib     - common libraries that applications may call; functions used by C compiler
     |
     |-- lost+found     - unreferenced files placed here by fsck (file system repair)
     |
/  --|
     |         |-- floppy     - /mnt is usually where optional disk drives get 'mounted'
     |-- mnt --|                to.  So if you insert a CD ROM, you normally cannot access
     |         |-- cdrom        the files in it till you have mounted it - e.g. to /mnt/cdrom
     |                          (However, some versions may automatically mount a CD.)
     |
     |-- net    - in a networked system, other machines' drives could be mounted under here
     |
     |-- opt    - place where some applications might get installed (netscape, oracle, etc.)
     |
     |-- root   - home directory of the root user (system administrator)
     |            Ordinary users should not be allowed to see what's in here.  
     |
     |-- sbin   - binaries for system administrator - e.g. shutdown
     |            Ordinary users should not be allowed to run these commands.  
     |
     |-- tmp    - temporary files; should be cleaned up after use
     |
     |         |-- bin       - more binaries 
     |-- usr --|
     |         |-- local     - important system-specific installations - e.g. jdk (Java dev. kit)
     |         |
     |         |-- ...       - other directories, e.g. /usr/X11 for the windowing software
     |
     |-- var    - /var/log usually contains important log files  

What you find when you explore your own system will almost certainly differ from this. Perhaps users' home directories are located somewhere under /usr/. Linux systems are quite often dual-boot Windows/Linux, which means that the hard drives have been partitioned in such a way that there is a complete installation of a Windows system in one part, and a complete Linux installation in another. In such a set-up, it would be natural to have a mount point (like /mnt/floppy) where the Windows partition (what would most likely be the C:\ drive as seen within Windows) can be accessed from within Linux. Much of these very notes were written from within Linux, but saved out to a Windows 95 directory. Where the Windows drive (or drives) is mounted within the Unix system, and what it is called, is a matter of taste; it could be /win. Similarly, a Linux box operating within an environment which has networked Novell drives could - if the appropriate Novell client libraries have been installed and configured - mount that networked files system, e.g. under /Novell.

The path to a file is its location within the file system. The absolute or full path to a file is its absolute location relative to the root directory. Thus

/usr/local/jdk/bin/javac
would be the full path for the the java compiler, javac, if the JDK (Java Development Kit) has been installed on the system under /usr/local/jdk. Notice how, as is quite typical for complex applications, the JDK has its own bin sub-directory, where all the relevant binaries are contained.

A relative path, as the name suggests, locates a file or directory relative to some other directory, often the one where you are currently located. Every Unix directory has two special directory references,

.   - the current directory
..  - the directory above
Thus, if you are currently situated in /usr/local/bin, then ../jdk/bin would be another way of specifying the directory /usr/local/jdk/bin.


Exercise

A good way to explore your file system is to use a web browser. If you are not currently in a graphical environment, try typing the command
startx
for Linux, or perhaps
openwin
for a Unix with Open Windows. In every case where you type in a command, enter the command by pressing the Return or Enter key.

If you have got a browser like Netscape available, type

file:/
in the URL Location text field, and get some initial familiarisation with the 'geography' of your system.

© INGENIO.co.uk