Linux File System tutorial

0 501

In this tutorial we will discuss about Red Hat linux file system structure. This file system structure is called Filesystem Hierarchy Standard (FHS).


This defines the names, location and permission of different file types and directories.

You will find files (programs) are located under /bin, or /sbin, or /usr/bin, or /usr/sbin?

We will now summarize directory structure in FHS.

When you open double click on computer in RHEL 7 you will see folders/directories.

All of these folders/directories have base/root path /(starting point) is “/” directory. This is often referred to root directory. Do not confuse this with /root directory.

We will Open file explorer and will see high level Linux directories. But before opening file explorer I will recommend to change default display view of explorer. I want to show you location of each folder and when you browse in file explorer Open file browser.

Logged into system click on places and then computer


Click Preferences


Click Display tab


Click on first drop down list and select location option


Click Close


Select Computer in Devices section. You will see top level directories.

  1. /  (root) directory

You see / under each directory that is starting point for each directory. In other words . Every single file and directory starts from the root directory. Only root user has write privilege under this directory. Please note that /root is root user’s home directory, which is not same as /.

  1. /bin – User Binaries

This directory contains binary executables also common Linux commands you need to use in single-user modes are located under this directory. Commands used by all the users of the system are located here.

For example: cp. cat, du, df, tar, ps, ls, ping, grep, rpm, wc, history,
3. /boot – Boot Loader Files

Everything which is needed to boot system is stored in /boot directory for example you can find Kernel initrd, vmlinux, grub files  under /boot directory. Do not delete this directory it will make your system unbootable

4. /dev – Device Files
The /dev/ directory contains file system entries which represent devices that are attached to the system. These include terminal devices, usb, or any device attached to the system. These files are essential for the system to function properly for example: cdrom, cpu,/dev/tty1, /dev/usbmon0


  1. /etc – Configuration Files

This directory contains configuration files required by all programs, startup and shutdown shell scripts used to start/stop individual programs. It contains lots of other files as well which belongs to different software. You should determine which program they belong to and read the manual page for that program. You wlll find network configuration files here, local name resolutions file (/etc/resolv.conf) and for logs /etc/logrotate.conf

  1. /lib – Essential Shared Libraries

Binaries file in usr/bin folder needs library files which are stored in /lib

The Lib directory contains kernel modules and shared library images required to boot the system and run commands in root file system

7. /sbin – System Binaries
This directory also contains binary executables but this directory contains commands

that is only accessed by system administrator for system administrative tasks like to check filesystem (fsck), to configure network (ifconfig) and other command like mount,reboot,fdisk,iptables, swapon etc

8 /lost+found – Recovered Files
Each Linux file system has a lost+found directory.If the file system crashes, a file system check will be performed at next boot. Any corrupted files found will be placed in the lost+found directory, so you can attempt to recover as much data as possible.

9 /media – Removable Media
The /media directory contains subdirectories where removable media devices inserted into the computer are mounted. For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

10 /mnt – Temporary Mount Points
Temporary directory for mounting  file system

11 /opt – Optional Packages
The /opt directory contains subdirectories for optional software packages. It’s commonly used by proprietary software that doesn’t obey the standard file system hierarchy – for example, a proprietary program might dump its files in /opt/application when you install it.

13 /proc – Process Information
The /proc directory similar to the /dev directory because it doesn’t contain standard files. It contains special files that represent system and process information. For example: /proc/{pid} directory contains information about the process with that particular pid. This is a virtual filesystem with text information about system resources. For example: /proc/uptime


14. /var – Variable Files
The /var directory is the writable counterpart to the /usr directory, which must be read-only in normal operation. Log files and everything else that would normally be written to /usr during normal operation are written to the /var directory. This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);



15. /tmp – Temporary Files
Directory that contains temporary files created by system and users.Files under this directory are deleted when system is rebooted.

16. /usr – User Programs
This directory Contains binaries, libraries, documentation, and source-code for second level programs. /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp. /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel. /usr/lib contains libraries for /usr/bin and /usr/sbin. /usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2

17. /home – Home Directories
Home directories are  for all users to store their personal files. For example: /home/aali, /home/john

18. /srv – Service Data
srv stands for service. The /srv directory contains “data for services provided by the system.” If you were using the Apache HTTP server to serve a website, you’d likely store your website’s files in a directory inside the /srv directory.This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS

19. /run – Application State Files
The /run directory is fairly new, and gives applications a standard place to store transient files they require like sockets and process IDs. These files can’t be stored in /tmp because files in /tmp may be deleted.

20. /root – Root Home Directory
This is home directory of root user (super admin). Home directory of all other users are under /home directory. Please do not confuse with / partition . /root is pronounced as  slash root.

Join us by subscribing to our newsletter and learn IT subjects for free
We hate spam. Your email address will not be sold or shared with anyone else.

Leave a reply

You must be logged in to post a comment.