Linux Directory Structure

ravindra bagale
4 min readJul 10, 2022

in this article we will see ,

what are the default directories which are created by-default by Linux operating system.

We will see this on Amazon Linux OS powered Ec2-Instance on AWS. To see these structures you can install “tree” command.

become root user to install tree

sudo su

Now install tree command

yum install tree -y

After successful installation , go to root folder

cd /root

Now enter below command to see all default directories

tree -L 1

Linux default directories

/bin directory:

The /bin directory contains command’s . that means binary or executable programs of normal commands .For e.g. ls, cp, cat, echo, df etc.

/bin directory

/boot directory:

It contains boot loader files.

/boot directory

/dev directory:

The /dev directory contains device files for all the hardware devices of your system. TTY is an abstract device in Linux. Sometimes it refers to a physical input device such as a serial port, and sometimes it refers to a virtual TTY where it allows users to interact with the system

/dev directory

/etc directory:

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

application specific configurations like Apache ,Nginx ,mysql and php configuration are done in /etc

/etc directory

/home directory:

The /home directory contains a home folder for each user. For example, if your user name is ec2-user, you have a home folder located at /home/ec2-user. 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.

/home/ec2-user directory

/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.

/mnt directory:

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

/opt directory:

The /opt directory contains optional or third party software

/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.

/proc directory

/root directory:

Home directory for the root user.

/run directory:

The /run directory stores system processes volatile runtime data.

/sbin directory:

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

/sbin directory

/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.

/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.

/usr directory

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.

After installing Apache, Apache uses directory /var/www/html as default directory to store website pages

/var directory

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.

--

--

ravindra bagale

10+ years in Cloud Architecture…. Devops Enginner and Technology lover from India