»
S
I
D
E
B
A
R
«
The Linux Filesystem Hierarchy
January 31st, 2011 by Carlo

One of the things that made me curious when I approached Linux for the first time was the long list of different directories that are part of a basic installation. The command ‘man’ helps in figuring this out when searching for ‘hier’, which stands for hierarchy:?

[carlo@dragon ~]$ man hier

Another good source of information for the file system hierarchy of Linux is available at TheĀ  Linux Documentation Project web site:

http://tldp.org/LDP/Linux-Filesystem-Hierarchy/Linux-Filesystem-Hierarchy.pdf

This is a 113 pages book in PDF format and is a good reference for those who want to know more. For the rest of us, here is a list of the most important directories in the hierarchy.
Keep in mind that different Linux distributions may use some of the directories in a slightly different way and, sometimes, even change the path of some of the contents described in this article.
However, the principle remain, and you can always type ‘man hier’ on the command line to learn how your particular distribution behaves, if something is different.

/ The so called “root” directory. Everything starts from here; all the other directory paths start from this root point.
/bin This is a container for the programs that are used in command line mode. Mostly, these are the programs that are used in day to day chores, from creating and destroying directories, to change ownerships, to make searches, and even provide shell environments. All these programs are executable binaries, from which the name of the directory: bin[ary].
/sbin The container for the system programs that are used to boot the system and to perform certain administrator tasks. Regular users usually don’t need to access the contents of this directory, although they are usually visible to everybody.
/boot The boot loader directory. It contains the boot loader itself, all its related files, and the kernel binary. When the system is powered on, the BIOS goes directly into this directory and starts the boot loader. This may present a list of Operating Systems to start, like Linux or Windows or OSX, then it loads the kernel into memory and gives control to it.
/dev This directory contains a list of the physical devices that are part of the system. In Linux, every device is represented as a file, so each device has an entry in this directory that emulates a file. Whenever you access a device, either a disk, or a USB device, or a console terminal, or any other, the OS thinks it is a file that is located in this directory and access it, like it was a real file. Low level drivers take care of converting the file access directives to actual directives for the device itself. If you have some knowledge of C++, you can easily see the concept when you think how all kind of devices can be accessed by a stream, simply using the iostream class or one of its derivatives.
/etc The repository for most of the system configuration files. Some very large packages have their configuration file in subdirectories of /etc. Otherwise, everything is located at this exact level. Example of configuration files stored in this directory are: bashrc, crontab, host.conf, inittab, netconfig, passwd, virc, yum.conf. Whenever aprogram is launched, it usually go into this directory to see if there is a centralized configuration file it should use.
/etc/opt This is a special subdirectory of /etc. While /etc is used to store configuration files for system applications, or applications that come with the operating system, /etc/opt is used to store configuration files for optional applications, those that can be installed from expernal repositories, or those that you can eventually create of buid yourself. These are applications that are normally stored in the /opt directory.
/home The default home directory for all users. Each user has usually its own subdirectory allocated right below /home. For example:
/home/carlo
/root The home directory of the root user. The root user or superuser is the main administrator of the system.
/lib The libraries directory. This is the place where all the shared libraries are stored. Shared libraries are those binary routines that are used by the programs but are not part of the programs themselves. When a specific functionality, or a set of them, can be used for different programs, it is usually put in such a library. Then, the programs don’t have to incorporate that code over and over again. Instead, they just link to the library that contains the code so they can use it. As you can imagine, this architecture has the advantage that a bug fixed for a specific functionality, that is fixed within a library, automatically and simultaneously fix the same bug in all the programs that use that functionality through the library. It is very effective and largely used.
/media Each storage device, before it can be used, needs to be mounted, otherwise the OS and the programs cannot access it. This directory is the place where removable media is mounted. CD-ROMs and USB disks, for example, are mounted in this directory and accessed from there.
/opt As already mentioned earlier, this is the directory where optional applications are installed. These are applications that are not specifically part of the distribution.
/proc This is a directory containing files that describe the current status of the system and all its processes. These files are continuously updated by the OS and we can only access them to read their content. Unfortunately, although the contents are written in text format, they are kind of criptic to understand. However, there are several programs and commands available that are made just for read and decode the contents of the proc files in a more human readable format. Commands like top and iostat, or applications like System Monitor, simply access the files in this directory and present their contents to you in a nice format.
/srv This is a repository for certain data used by the system when it is used as a server. It usually comes empty with a new installation.
/tmp A temporary container for everybody to use. Depending on the policy defined for the system, files in this directory can be deleted without notice, either because they are odler than a certain age, or at predetermined days and times. Certain programs use this directory to hold temporary data. Users can put files in it too, but they have to be aware that they are not going to stay there forever.
/usr This is the directory containing programs for the regular users, their documentation, everything related to X, files used by compilers, libraries, and a lot of other interesting stuff. To stalk abou tthis directory alone, it would take a lot of space so, just go browse into it; you’ll be surprised by the amount of information in it. This directory was the original home directory for all the users in the UNIX systems, but its usage has been restricted more and more over time, until today is only usage for files that are of support for the users. The home for the users has moved to /home. However, some UNIX versions still use /usr the way it was originally intended.
/var This directory is divided in several subdirecories. It is the repository for most of the log files generated in the system, along with some configuration files, cache, users’ mailboxes, spools for various programs, and a lot more.

Comments are closed

»
S
I
D
E
B
A
R
«

INFORMATION IN THIS WEB SITE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED. THE USER ASSUMES THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THIS INFORMATION.

Trademarks: All brand names and product names used in this web site are trade names, service marks, trademarks, or registered trademarks of their respective owners. Dazzling Solutions is not associated with any product or vendor mentioned in the site, unless otherwise specified.

»  Substance: WordPress   »  Style: Ahren Ahimsa