Archive for December, 2007

The Linux file system heirarchy

Monday, December 17th, 2007

Let’s look at the Linux file system arrangement, it is almost similar to the Windows system as they are arranged in a hierarchical directory structure, similar to a tree structure, one directory containing many files or subdirectories, which in turn containing more. In Linux system all the files and directories are under a single tree called the root directory represented as < / > (slash) unlike windows where one tree starts from C:, other starts from A:, D: etc.

 

< / >

The root directory is the starting point of your directory structure. This is where the Linux system begins. Every other file and directory on your system is under the root directory. Usually the root directory contains only subdirectories, so it’s a bad idea to store single files directly under root.

 

< /boot >

As the name suggests, this is the place where Linux stores all information that it needs when booting up.

 

< /etc >

It contains the configuration files for the Linux system. Most of these files are text files and can be edited.

 

< /bin, /usr/bin >

These two directories contain a lot of programs (binaries) for the system. It contains the most important programs that the system needs to operate, such as the shells and other essential things.

 

< /sbin, /usr/sbin >

Programs mostly related to system administration are stored in these directories.

 

< /usr >

This directory contains user applications and other related things for them, like their source codes, and pictures, docs, or configuration files they use.

 

< /lib >

Contains shared libraries for programs that are dynamically linked. Shared libraries are similar to dll’s on Windows.

 

< /home >

This is where users keep their personal files.

 

< /root >

The superuser’s (root’s) home directory. Don’t confuse this with the root directory < / > of a Linux system. This is preferably used by system administrators

 

< /tmp >

Programs can write their temporary files here.

 

< /dev >

Contains devices that are available to a Linux system. Remember that in Linux, devices are treated like files and you can read and write devices like they were files. For example, /dev/fd0 is your first floppy drive, /dev/cdrom is your CD drive, /dev/hda is the first IDE hard drive, and so on. All the devices that a Linux kernel can understand are located under /dev.

 

< /mnt >

This directory is used to mention mount points. Physical storage devices (like the hard disk drives, floppies, CD-ROM’s) must be attached to some directory in the file system tree before they can be accessed. This is called mounting, and the directory where the device is attached is called the mount point. The /mnt directory contains mount points for different devices, like /mnt/floppy for the floppy drive, /mnt/cdrom for the CD-ROM, and so on. However, you’re not forced to use the /mnt directory for this purpose, you can use whatever directory you wish.

 

< /proc >

This is a special directory. Well, actually /proc is just a virtual directory, because it doesn’t exist at all! It contains some info about the kernel itself.

 

< /lost+found >

Here Linux keeps the files that it restores after a system crash or when a partition hasn’t been unmounted before a system shutdown. This way you can recover files that would otherwise have been lost.