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 /
Table of Contents
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.
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.
It contains boot loader files.
The /dev directory contains device files for all the hardware devices part of your system
The /etc directory contains the system configuration files. These files include username, password, network config, application specific config, system startup/shutdown files, etc.
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.
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
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.
The /mnt directory contains mount points for the temporary files system.
The /opt directory contains optional or third party software
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.
Home directory for the root user.
The /run directory stores system processes volatile runtime data.
The /sbin directory contains binary executable programs for an administrator.For e.g. fdisk, fsck, reboot, shutdown, iptables.
The /snap directory contains the mount-points for your snaps and several symlinks which are needed by snapd.
It is a virtual filesystem for modern Linux distributions to store and allows modification of the devices connected to the system.
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.
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.
If you wants to check this directories in tree the run the command
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 .
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.
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.
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.