Monday, 25 December 2017

Linux is a multitasking operating system which has a very different file-system unlike other Unix-like operating system. As a future Linux System administrator, one has to know what is / directory, what is inside each of directories such as /bin, /boot, /etc/, /sbin, /var and so on. In this Linux article you gonna find out the Linux file-system hierarchy and the contents of each of it's folder. Note: This article is part of my Linux LPIC-1 (Linux System administrator) intensive preparation and it is granted to be republished to other Linux related sites, to be commented and so on.

Written by: Amar Tufo
25. December 2017

Figure 1: Linux FS hierarchy 
Figure by: Amar Tufo

This is how a Linux file-system look like. Now, I'm going to explain each of the directories within the Linux file-system hierarchy starting from the (/) root directory. The article it self is going to be slightly longer but I will try to explain it to you as much as I can. Please comment down bellow for any error you see in the figure it self or in my text. 

1. /

The root file-system or root directory is a directory that contains all other directories and files on the system. It is designated by forward (/) slash. It's a top level directory in Linux file-system hierarchy. As a top level directory, it contains other sub-directories such as /bin, /sbin, /etc/, /dev/, /proc, /var and etc. The system administrator and other users who have the appropriate permissions can create additional directories within the root directory if desired. The content of the root directory can be viewed by typing the following command.

ls /

Figure 2: The / file-system
Figure source: /home/amar/Desktop/figure2.png

You may like this article as well:
Linux Booting process in 6 steps

2. /bin 

/bin directory is standard subdirectory of the root directory that contains the executable (ready to run) programs  that must be available in order to attain minimal functionality for the purposes of system booting.  Among the contents of /bin directory are the shells (bash and csh), common commands such as ls, grep, tar, kill, echo, pd, cp, mv, rm, cat and others. 

Figure 3: The content of  /bin directory 
Figure source: /home/amar/Desktop/figure3.png

3. /sbin 

It's a directory which holds the system binaries or mostly the admin tools. It's similar to /bin directory, except that /sbin programs required root password in order to be executed. Among the programs inside /sbin directory tools such as fdisk, fsck, reboot, depmod, runlevel and others. Check the figure 4 down bellow.

Figure 4: The content of /sbin directory
Figure source: /home/amar/Desktop/figure4.png

Sponsored content:
Imtec - Computers and Technology

4. /etc 

This is the nerve center of your system as it contains all system related configuration files. A 'configuration file' is defined as a local file which is used to control the operation of a program. It must be static and cannot be an binary. Among the contents of  /etc directory are the following config files.

* /etc/x11 - this file contains all the configuration for the X Window System.

* /etc/apt - It's Debian's next generation front - end for the dpkg package manager. It provides the apt-get utility and APT dselect method that provides a simpler, safer way to install and upgrade packages.

* /etc/apt/sources.list - It contains a list of apt-sources from which packages may be installed via APT.

Each of these config files can safely be viewed using cat command like cat /etc/apt/sources.list which is shown in figure 5 down bellow.

Figure 5: Content of /etc/apt/sources.list file
Figure source: /home/amar/Desktop/figure5.png

This article is proudly written using Linux Mint 18.2 Sonya with MATE desktop environment.

5. /dev

The /dev directory contains the special device files for all devices. These devices are created during installation and later with the /dev/MAKEDEV script. Some of the files located within /dev directory are:

* /dev/dsp - Digital Signal Processor - interface between software which produces sound and your soundcard.

* /dev/hda - It is the master device IDE drive on the primary IDE controller.

6.  /proc

Figure 6: The content of /proc directory
Figure source: /home/amar/Desktop/figure6.png

The /proc file-system contains a illusionary file-system. It does not exist on a disk. Instead, the kernel creates it in a memory. It is used to provide information about the system processes. Some of the more important files are:

* /proc/1 - A directory with information about process number 1.

* /proc/devices - List of device drivers configured into the current running kernel.

* /proc/dma - Shows which DMA channels are being used at the moment.

* /proc/interrupts - Shows which interrupts are in use and how many of each of there have been. (See figure 7 down bellow)

 Figure 7: Listing /proc/interrupts
Figure source: /home/amar/Desktop/figure7

Book recommendation:
Linux LPIC-1 
Learn everything you need in order to pass Linux LPIC-1 exam to become Linux SysAdmin
Download URL:

7. /var 

Figure 8: The content of /var/log directory
Figure source: /home/amar/Desktop/figure8.png

The /var directory contains data that is changed when the system is running normally. It is specific for each system. Some ot the important files are listed down bellow. 

* /var/lib - Files that change while the system is running normally.

* /var/log - Log files from various programs, especially login (/var/log/wtmp) which logs all logins and logouts into the system. Syslog (var/log/messages) contains all kernel and system messages. 

8. /tmp

Figure 9: The content of /tmp directory
Figure source: /home/amar/Desktop/figure9.png

This directory contains mostly files that are required temporarily. Many of these files are important for currently running programs and deleting them may result in system failure. For more about /tmp directory please check out the link down bellow in references.


Knowing the Linux file-system hierarchy may not be so important as it seems, but as a Linux System administrator you always work with the common commands such as cp, cd, mkdir, ls, grep, tar and others, therefore is good to know in which directory (/bin) you can find them. The same case goes for /proc folder which is very important to know when working with system processes and etc. In the next part of Linux FS, we gonna take a look on the rest of Linux file-system hierarchy. Till then, Marry Christmas and I see you soon.


1) The Linux File-system hierarchy 

2) The root directory

3) The /bin directory

4) The /sbin directory

5) The /etc directory

6) The /dev directory

7) The /proc directory

8) The /var directory

9) The /tmp directory

0 komentari:

Post a Comment


My Twitter news

Follow me on Facebook:

Popular Posts