Linux Command - Linux Directory Structure
The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Linux distributions.
FHS is maintained by the Linux Foundation. current release is FHS 3.0. FHS enable software to predict the location of
installed files and directories and users to predict the location of installed files and directory.
FHS 3.0 specification can be found from http://refspecs.linuxfoundation.org/fhs.shtml
See directory structure
/ - Root
Everything is located under / directory
/bin - Essential command binaries
- /bin contains essential programs used by system admins and users.
- no subdirectories allowed in /bin
In Ubuntu /bin is a symbolic link to usr/bin
/boot- Static files of the boot loader
contains files used to boot the system. e.g. the GRUB boot loader.
/dev - Device files
The /dev directory is the location of special or device files. virtual device are also here.
Some of the most important files are /dev/null, /dev/tty, /dev/random.
/etc - Host-specific system configuration
/etc directory contains config files. all files must be static and cannot be executable binary.
important files are /etc/hosts. /etc/init.d/ is the directory that contains all the service init script.
/home - home directory
Optional. linux create a home folder for each user. if the user’s name is alice, the home directory
for alice will be /home/alice/. Each user has write permission to their own home folder only. The user
need to obtain elevated permissions(become root) to modify other files.
/lib - Essential shared libraries and kernel modules
/lib directory contains shared library needed to boot the system and run the commands in the root filesystem.
/media - Mount point for removable media
contains subdirectories used as mount points for removable media such as floppy disks, cd roms.
/mnt - Mount point for mounting a filesystem temporarily
/mnt directory is used to mount a filesystem as needed
/opt - Add-on application software packages
/opt directory contains subdirectories for optional software packages.
/root - Home directory for the root user
/root directory is optional. It is the recommended home directory for the root user.
/run - Run-time variable data
This directory contains system information data describing the system since it was booted.
/sbin - Essential system binaries
/sbin is similar to /bin directory. contains essential binaries for admin user.
In Ubuntu /sbin is a symbolic link to usr/sbin
/srv - Service Data
/srv contains site-specific data which is served by this system. Use it if serving a website.
/tmp - Temporary files
For storing temporary files. files in /tmp will be deleted when system is restarted
/usr - User Binaries & Read-Only Data
usr is for Unix Software Resource. It contains Read-Only data.
The most important subdirectory is /usr/bin. It is the primary directory of executable commands on the system, Commonly used applications like git, node, python are here. even user application like firefox, vs code are install here
Subdirectories
Directory | Description |
---|---|
/usr/bin | primary directory of executable commands on the system. In Ubuntu, commonly used commands such as ls, ps, tar, less… are installed here |
/usr/sbin | Non-essential standard system binaries |
/usr/local/bin | Local binaries |
/usr/local/etc | Host-specific system configuration for local binaries |
/usr/local/sbin | Local system binaries |
/usr/local/bin and usr/local/sbin are are both added to the system path. Executables local to the site are installed here. You can add user scripts and binaries here so that they are added to the system path automatically.
/var - Variable data
/var is the writable counterpart to the /usr directory. log files, cache files are here.