Linux Directory Structure Explained for Beginners

In this article we are going to cover How Files and Folders are organized in Linux, Linux Directory Structure.

The Filesystem Hierarchy Standard (FHS) defines the structure of file systems on Linux and other UNIX-like operating systems.

And here i will use ubuntu 20.04LTS server to make you understand the directory structure

Here I have used tree command to list down the content of a directory in a tree-like format.

You can install tree using following command

apt install tree 

tree -L 1 /
Linux Directory Structure Explained for Beginners 1
tree

Linux Directory Structure Explained for Beginners

/ (root) directory :

The directory called “root.” It is the starting point for the file system hierarchy. Note that this is not related to the root, or superuser, account.

/bin directory:

The /bin directory contains binary or executable programs and need to be used when performing file system repairing etc. For e.g. ls, cp, cat, echo, df etc.

Linux Directory Structure Explained for Beginners 2
bin

/boot directory: 

It contains boot loader files.

Linux Directory Structure Explained for Beginners 3
boot

/dev directory:

The /dev directory contains device files for all the hardware devices part of your system

Linux Directory Structure Explained for Beginners 4
dev

/etc directory:

The /etc directory contains the system configuration files. These files include username, password, network config, application specific config, system startup/shutdown files, etc.

Linux Directory Structure Explained for Beginners 5
etc

/home directory:

The /home directory contains a home folder for each user. For example, if your user name is demo, you have a home folder located at /home/demo. This home folder contains the user’s data files and user-specific configuration files. Each user only has write access to their own home folder and must obtain elevated permissions (become the root user) to modify other files on the system.

Linux Directory Structure Explained for Beginners 6
home

/lost+found directory:

The lost+found directory is a construct used by the fsck system utility. It’s a special directory that contains data that has become obsolete. The fsck utility creates it on a Linux machine with partitions of the Extended File System

Linux Directory Structure Explained for Beginners 7
found

/media directory:

The /media directory contains subdirectories where removable media devices inserted into the computer are mounted. For example, when you insert a CD into your Linux system, a directory will automatically be created inside the /media directory.

Linux Directory Structure Explained for Beginners 8
media

/mnt directory:

The /mnt directory contains mount points for the temporary files system.

Linux Directory Structure Explained for Beginners 9
mnt

/opt directory:

The /opt directory contains optional or third party software 

Linux Directory Structure Explained for Beginners 10
opt

/proc directory:

The /proc directory is a virtual and pseudo-file system to contain info about the running processes with a specific process ID or PID.Under this directory the files and directories gets generated as and when system starts or something changes on the system.

Linux Directory Structure Explained for Beginners 11
proc

/root directory:

Home directory for the root user.

Linux Directory Structure Explained for Beginners 12
root

/run directory:

The /run directory stores system processes volatile runtime data.

Linux Directory Structure Explained for Beginners 13
run

/sbin directory:

The /sbin directory contains binary executable programs for an administrator.For e.g. fdisk, fsck, reboot, shutdown, iptables.

Linux Directory Structure Explained for Beginners 14
sbin

/snap directory:

The /snap directory contains the mount-points for your snaps and several symlinks which are needed by snapd.

Linux Directory Structure Explained for Beginners 15
snap

/sys directory:

It is a virtual filesystem for modern Linux distributions to store and allows modification of the devices connected to the system.

Linux Directory Structure Explained for Beginners 16
sys

/tmp directory:

This directory contains temporary files. These files are generally deleted whenever your system is restarted and may be deleted at any time by utilities such as tmpwatch.

Linux Directory Structure Explained for Beginners 17
tmp

/usr directory:

This directory contains applications, libraries, docs, icons, images and other files which needs to be shared by applications and services. It is basically shareable, read-only data.

Linux Directory Structure Explained for Beginners 18
usr

If you wants to check this directories in tree the run the command

Linux Directory Structure Explained for Beginners 19

Sub directories of /usr directory

/usr/include :- Standard include files.

/usr/lib :- Libraries for the binaries in /usr/bin and /usr/sbin.

/usr/lib<qual> :- Alternative-format libraries 

/usr/local :- Contains local data specific to this host. Typically has further subdirectories 

/usr/sbin :- Non-essential system binaries 

/usr/share :- Architecture-independent (shared) data.

/usr/src :- Source code .

/var directory:

The /var directory contains variable files such as log files, lock, mail, cache and temp files that change constantly when the system is running and are expected to grow further.

Linux Directory Structure Explained for Beginners 20
var

Sub directories of /var directory

/var/cache :- Application cache data.

/var/lib :- State information. Persistent data modified by programs as they run.

/var/lock :- Lock files. Files keeping track of resources currently in use.

/var/log :- Log files. Various logs.

/var/mail :- Mailbox files. In some distributions, these files may be located in the deprecated /var/spool/mail.

/var/opt :- Variable data from add-on packages that are stored in /opt.

/var/run :- Run-time variable data. This directory contains system information data describing the system since it was booted. In FHS 3.0, /var/run is replaced by /run.

/var/spool :- Spool for tasks waiting to be processed .

/var/tmp :- Temporary files to be preserved between reboots.

Conclusion:

In this article we have covered Linux Directory Structure Explained for Beginners, Linux File System Hierarchy, Linux directory structure command, Linux directory structure cheat sheet.

Related Articles:

How to Configure Postfix with Gmail on Ubuntu

Reference:

Linux directory structure explained in details

Shweta Mamidwar

I am Shweta Mamidwar working as a Intern in Product Company. Likes to share knowledge.

1 thought on “Linux Directory Structure Explained for Beginners”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap