Linux Directory Guide
I have been using Linux since 2001 (starting with Mandrake Linux), but even with years of usage, the directory structure can still be confusing.
Therefore, outlined below is a handy guide, which outlines the first level of the directory tree, including descriptions. Although minor differences will exist, this should be the same for all major Linux distributions (Ubuntu, RHEL, Fedora, etc.)
-
/ - The root directory. Only the root user has write privilege under this directory.
-
/bin/ - User binaries (applications) that must be present when the system is mounted in single-user mode. For example, system applications and utilities such as the bash shell are located in “/bin/”.
-
/boot/ - Boot loader files, including GRUB and Linux kernels. The boot loader configuration files are located in “/etc/”.
-
/dev/ - Device and virtual-devices files. For example, Linux exposes devices as files, where “/dev/sda/” would represent a SATA device.
-
/etc/ - System configuration files. User configuration files are located in the user home directory.
-
/home/ - User home directory, containing user data files and configuration files.
-
/lib/ - Essential shared libraries, needed by the essential binaries in the “/bin/” and “/sbin/” directories.
-
/media/ - Removable media, where removal media devices are mounted. For example, optical media.
-
/mnt/ - Temporary Mount Points, where other temporary file systems are mounted.
-
/opt/ - Optional packages, used for add-on applications and proprietary software.
-
/proc/ - Kernel and process files, including information about running process. For example, the “/proc/{pid}/” directory contains information about the process with that particular process ID.
-
/root/ - The home directory of the root user. For example, the root user is not located at “/home/root/”.
-
/sbin/ - System binaries, containing essential binaries used by the root user for system administration.
-
/selinux/ - Security-Enhanced Linux (SELinux) is a Linux kernel security module that provides a mechanism for supporting access control security policies, including mandatory access controls. SELinux is used by Red Hat Enterprise Linux and Fedora.
-
/srv/ - Service data, containing data for services provided by the system. For example, web assets being served by a HTTP web server.
-
/tmp/ - Temporary files, which are commonly deleted as part of housekeeping activities.
-
/usr/ - User binaries and read-only data, containing applications and files used by the user. For example, non-essential applications are located inside the “/usr/bin/” directory instead of the “/bin/” directory.
-
/var/ - Variable data files, providing a writable location for the “/usr/” directory. For example, log files.
To explore your directory structure, I would recommend using the “tree”, which is a Linux tool designed to show the directory tree.
To install “tree” on Ubuntu, simply running the following terminal command:
sudo apt install tree
To install “tree” on RHEL or Fedora, simply running the following terminal command:
sudo dnf install tree
Once installed, run the command:
tree -L 1 /
This command will show the first level of the directory tree starting at the root directory.