For anyone, who is a beginner on working with Linux OS, might feel difficulty in understanding the file hierarchy structure and the purpose each directory serves.
So, I'm writing this because I felt the same.
This article will provide information of Linux file hierarchy structure, locations and its usability.
Each of the above directories contains important information. We will see this hierarchically.
- Primary root hierarchy and root directory of entire file system hierarchy
- /root is root user's home directory should not be confused with "/"
- Each directory and file starts from root directory
- Only root user has right to write under this directory
- Contains executable binary files
- Files requires to run as single-user mode
- Other essential commands like cat, ls, wc, tar, df, ping etc are located here
- Contains boot loader files required during boot up process
- Eg: Kernels, grub files
- Contains device files that requires for hardware devices on the machine
- Eg: cpu, cdrom
- Host specific system-wide configuration files are available here
- Contains configuration files for individual programs
- Contains startup and shutdown script required to start/stop the individual programs
- Eg: /etc/resolv.conf
- Home directory of users
- Every time when user is created, a directory in the name of user is created under this directory
- User can store their personal files
- Eg: /home/sathish
- Contains library files that required for /bin/ and /sbin/
- In simple words, these files are used by a program or command or process for proper execution
- Mount points for removable devices such CD-ROM, USB etc.
- Temporary mount directory for removable devices
- /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer
- Temporarily mounted file systems
- Where sysadmins can mount file systems
- Optional software application software packages
- Contains 3rd party application software
- Eg: /opt/java
- Contains essential system binaries
- Contains linux commands that are used by sysadmins
- Eg: iptables, reboot, fdisk, ifconfig, swapon
- srv stands for service
- Contains server specific and service related files
- System's temporary directory
- Accessed by all users and root
- Store temporary file for users and system, available till next boot
- Secondary hierarchy for read-only user data
- Contains majority of multi-user utilities and application
- Contains binaries, libraries, documentation and source-code for second level programs
- User binaries that are unavailable in /bin, can be found under /usr/bin/ which contains user binaries
- System binaries that are unavailable in /sbin, can be found under /usr/sbin/ which contains system binaries
- /usr/lib contains binaries for /usr/bin and /usr/sbin files
- /usr/local contains user programs that installed from source
- Virtual and pseudo file system which contains all the running process with processid aka pid
- Stands for variable
- This directory is expected to grow
- Contains logs, lock, spool and temp files
Hope the above information helps.
P.S. This is my first blog written. So, please be kind enough and feel free to point out the mistakes.