FHS
This article we will look around a GNU/Linux System. The Filesystem Hierarchy Standard (FHS) defines the standard of directory configuration regarding Linux system.
According to a file system using frequently or not and whether a user is allowed to change freely, the directory is defined four interaction forms by FHS.
- shareable
- unshareable
- static
- variable
Directory introduce
- / (root): related to boot system. The root directory is the most important in entire system, because not only all directories are derived from root, but also it is related to the operation of boot,reduction and system repair and so on.
- /usr (UNIX software resource): related to software install and execute
- /var (variable): related to the operation of the system
Here is a directory tree and diagram showing some of the common directories right beneath the root directory whose name is just “/”.
Directory Tree
If you want to look into the structure of a directory, you can use bash command tree to list contents of directories in a tree-like format. For example, now we want to scan sub-directories of root(“/”) directory, we can type this in bash shell:
gehan@gehan-Lenovo-G480:~$ cd /
gehan@gehan-Lenovo-G480:/$ tree -d -L 1
.
├── bin
├── boot
├── cdrom
├── dev
├── etc
├── home
├── lib
├── lib32
├── lib64
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
22 directories
gehan@gehan-Lenovo-G480:/$
So we can see there are 22 one-level directories under root. For the options that used by tree
, their detail can be obtained by type man tree
.
- -d: List directories only.
- -L: Max display depth of the directory tree.
- and so on.
Diagram
Most of the time you don’t need to know about the directory structure outside your home directory, but this knowledge occasionally comes in handy. Perhaps the most common uses are when you want to change a system-wide configuration file or view log messages, which record things going on and may reveal the source of problems on your system. (Log messages are usually found in the /var/log directory.)
Dirs | Contents |
---|---|
/bin | basic programs (Programs that are absolutely needed, shell and commands only) |
/boot | initialization files (Required to actually boot your computer) |
/dev | device files (Describe physical stuff like hard disks and partitions) |
/etc | configuration files |
/home | user’s home directories |
/lib | basic libraries (Required by the basic programs) |
/media | mount points for removable media |
/mnt | mount points (For system admins who need to temporarily mount a filesystem) |
/opt | third-party programs |
/proc | process filesystem (Describe processes and status information, not stored on disk) |
/root | system administrator’s files |
/sbin | basic administration programs (Like bin, but only usable by administrator) |
/srv | service-specific files |
/sys | system filesystem (Similar to process, stored in memory based filesystem: tempfs) |
/tmp | temporary files (Files not kept between boots, often in tempfs) |
/usr | most programs (Another bin,etc,lib,sbin, but for less important files) |
/var | variable data (Similar to tmp, but preserved between reboots) |
Reference
- FHS standard official document: http://www.pathname.com/fhs/ “FHS”
- die.net:http://linux.die.net/man/1/tree “tree command”