Uses of each directories in Linux every DevOps engineer should
master
1. / (root directory): This is the top most directory in the Linux filesystem. All other
directories branch out from here, such as /etc, /var, and /usr. Every file and folder in
the system can be traced back to /. You can also check the disk usage of top level
directories under / with: du -sh /*
2. /home: This directory contains the personal folders for all regular users. When you
create a new user, a folder is created inside /home (e.g., /home/olayemi) to store their
personal files, scripts, and configurations, including SSH keys.
3. /root: This is the home directory of the root (administrator) user. Just like normal
users store their files in /home/username, the root user stores personal files,
configurations, and scripts in /root. It is separate from /home and since only the root
user should have access. You can switch to root user by using sudo -i command
4. /etc: This directory stores system configuration files and settings. For example:
Configuring services like Nginx, you can specify which directory it should serve
HTML files from and which port it should listen on. User, group, and password
information is also stored here, for example in files like /etc/passwd and /etc/group.
5. /var: This directory is used for variable. It stores files that tend to change frequently
while the system is running. For example logs in /var/logs. Also, your default website
files stores in /var/www/html
6. /bin: This directory stores your essential command binaries. It consists of the
command you run daily which includes ls, cp, mv, pwd, cd etc. It stores the command
and the behavior of the command
7. /sbin: This is quite related to /bin but here it contains commands that are used for
system administrations. Most of the time it needs administrative privilege before you
can run commands in /sbin. It includes commands like ifconfig, ip, reboot, shutdown,
fdisk
8. /usr: this is the part where files of installed application/ software are stores. In the
/usr/bin the commands used in the applications are stored. While in /usr/sbin the
administrative command of the application is stored here. /usr/share stores the
Documentation and libraries for the software.
9. /tmp: This is a temporary directory used to store files needed only while the system is
running. Programs and users place temporary data here, such as caches or
intermediate files. On most Linux systems, the contents of /tmp are automatically
cleared on reboot.
10. /opt: When you install software that’s not managed by the package manager (like apt,
yum, or dnf), this type of softwae often gets placed under /opt.
11. /dev: The name dev stands for device. When a device wants to interact with your
Linux system, Linux creates or uses the appropriate device file in /dev. Programs or
the kernel read from or write to that file, and Linux translates those file operations
into actual commands to the hardware.
Example use case: When you attach an EBS volume to your VM, Linux assigns it a
device file in /dev (e.g., /dev/xvdf). This file acts as the interface between the system
and the EBS volume, allowing Linux to read from or write to it just like a normal
disk.
12. /mnt: This stands for mount. It is a temporary folder used to attach external storage
devices or EBS volumes to a Linux system. For example, you can create a folder like
/mnt/ebs and mount your storage disk or EBS volume there. Once mounted, anything
you store in /mnt/ebs will actually be saved on the attached storage.
13. /media: This directory is used for automatically mounting removable devices like
USB drives, SD cards, and CDs. When you plug in a USB stick, Linux creates a
folder under /media/username/DEVICE_NAME, and the files on the device become
accessible there. Anything you save in that folder is actually stored on the removable
device itself, not on your root disk.
14. /lib: This directory contains essential libraries that programs need to run. Programs in
/bin and /sbin use these libraries as helpers to perform tasks. In summary, /bin and
/sbin runs the command and /lib tells how the command should work. Without /lib,
many commands and system programs would not work.