Sunday, July 19, 2009

Linux File System Hierarchy

Because everything in Linux is a file, you, as an administrator, are ultimately going to have to deal with files. This makes it very important to understand the Linux file system hierarchy. Most Unixes/Linuxes adhere to the Filesystem Hierarchy Standard which defines a universal/standard directory structure for a Linux/Unix operating system.

Here is a brief overview of the most commonly available directories on a standard Linux system and their purpose:

/bin = houses basic binaries like ls, cat, mv, date, kill, and ps etc.
/boot = houses boot and kernel-specific files.
/dev = houses device files.
/etc = houses host-specific configuration files.
/home = houses user-specific home directories.
/root = home directory of root user.
/lib = houses shared library files used by various programs.
/lost+found = contains files/directories that have gone corrupted, items referred to by bad inodes, lost file fragments and the likes.
/mnt = houses mount points for various removable devices like CD and Floppy.
/opt = houses add-on applications (StarOffice from Sun Microsystems, for example).
/proc = a virtual directory providing stats on file system, processor, and memory etc.
/sbin = houses system binaries (such as reboot, halt, route, and fdisk) accessible to root only.
/tmp = a location for storing temporary data.
/usr = houses applications that are accessible to ALL users on the system such as a Web browser and gzip.
/var = provides space for housing data that changes frequently such as print/mail jobs and log files.


Linux System Manuals

Linux manuals are typically stored in 9 structures -- man1 through man9. The manpath command shows the locations where manuals are located. Typically, manuals are stored under /usr/share/man.

Here is a brief description of what goes into each man structure:

man1 = user tools manuals
man2 = system calls manuals
man3 = c calls manuals
man4 = device driver manuals
man5 = configuration file manuals
man6 = game manuals
man7 = installation package manuals
man8 = system tools manuals
man9 = kernel manuals

The syntax of the command is:
# man

If a command is available in multiple manuals, you can specify which manual you want to look at by specifying the manual number like this:
# man [1-9]