- Understanding the Linux file system directories / hierarchy
- Exploring Linux File System Hierarchy
- How do I get information about each and every directory from command prompt?
- List contents of directories in a tree-like format
- Linux File Hierarchy Structure
- Национальная библиотека им. Н. Э. Баумана Bauman National Library
- Персональные инструменты
- FHS (File System Hierarchy Standard)
- Содержание
- История FHS
- Общие сведения о стандарте FHS
- Разделяемость файлов
- Изменяемость файлов
- Структура каталогов
Understanding the Linux file system directories / hierarchy
I’ve already written about conceptual information regarding file system, especially data structure and related terms that help you become a successful system administrator. However I do get few emails asking about /opt directory or /usr or /lost+found directories and their purpose on the system.
Exploring Linux File System Hierarchy
A typical Linux system has the following directories:
=> / : This is the root directory.
=> /bin : This directory contains executable programs which are needed in single user mode and to bring the system up or repair it.
=> /boot : Contains static files for the boot loader. This directory only holds the files which are needed during the boot process.
=> /dev : Special or device files, which refer to physical devices such as hard disk, keyboard, monitor, mouse and modem etc
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
=> /etc : Contains configuration files which are local to the machine. Some larger software packages, like Apache, can have their own subdirectories below /etc i.e. /etc/httpd. Some important subdirectories in /etc:
- /etc/skel : When a new user account is created, files from this directory are usually copied into the user’s home directory.
- /etc/X11 : Configuration files for the X11 window system .
- /etc/sysconfig : Important configuration file used by SysV script stored in /etc/init.d and /etc.rcX directories
- /etc/cron.* : cron daemon configuration files which is used to execute scheduled commands
=> /home : Your sweet home to store data and other files. However in large installation yhe structure of /home directory depends on local administration decisions.
=> /lib : This directory should hold those shared libraries that are necessary to boot the system and to run the commands in the root filesystem.
=> /lib64 : 64 bit shared libraries that are necessary to boot the system and to run the commands in the root filesystem.
=> /mnt : This directory contains mount points for temporarily mounted filesystems
=> /opt : This directory should contain add-on packages such as install download firefox or static files
=> /proc : This is a mount point for the proc filesystem, which provides information about running processes and the kernel.
=> /root : This directory is usually the home directory for the root user.
=> /sbin : Like /bin, this directory holds commands needed to boot the system, but which are usually not executed by normal users, root / admin user specific commands goes here.
=> /tmp : This directory contains temporary files which may be deleted with no notice, such as by a regular job or at system boot up.
=> /usr : This directory is usually mounted from a separate partition. It should hold only sharable, read-only data, so that it can be mounted by various machines run ning Linux (useful for diskless client or multiuser Linux network such as university network). Programs, libraries, documentation etc. for all user-related programs.
=> /var : This directory contains files which may change in size, such as spool and log files.
=> /lost+found : Every partition has a lost+found in its upper directory. Files that were saved during failures are here, for e.g ext2/ext3 fsck recovery.
How do I get information about each and every directory from command prompt?
Above list just summaries important directories, you can get list by entering the following command to display description of the file system hierarchy (works under all other UNIX like oses such as HP-UX ):
$ man hier
List contents of directories in a tree-like format
ls command is basic tool for exploring file system. You can use tree command for a recursive directory listing. It produces a depth indented listing of files.
$ tree
Output:
find is another useful command to search for files in a directory hierarchy.
Источник
Linux File Hierarchy Structure
The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix-like operating systems. It is maintained by the Linux Foundation.
- In the FHS, all files and directories appear under the root directory /, even if they are stored on different physical or virtual devices.
- Some of these directories only exist on a particular system if certain subsystems, such as the X Window System, are installed.
- Most of these directories exist in all UNIX operating systems and are generally used in much the same way; however, the descriptions here are those used specifically for the FHS and are not considered authoritative for platforms other than Linux.
1. / (Root): Primary hierarchy root and root directory of the entire file system hierarchy.
- Every single file and directory starts from the root directory
- The only root user has the right to write under this directory
- /root is the root user’s home directory, which is not the same as /
2. /bin : Essential command binaries that need to be available in single-user mode; for all users, e.g., cat, ls, cp.
- Contains binary executables
- Common linux commands you need to use in single-user modes are located under this directory.
- Commands used by all the users of the system are located here e.g. ps, ls, ping, grep, cp
3. /boot : Boot loader files, e.g., kernels, initrd.
- Kernel initrd, vmlinux, grub files are located under /boot
- Example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic
4. /dev : Essential device files, e.g., /dev/null.
5. /etc : Host-specific system-wide configuration files.
- Contains configuration files required by all programs.
- This also contains startup and shutdown shell scripts used to start/stop individual programs.
- Example: /etc/resolv.conf, /etc/logrotate.conf.
6. /home : Users’ home directories, containing saved files, personal settings, etc.
- Home directories for all users to store their personal files.
- example: /home/kishlay, /home/kv
7. /lib : Libraries essential for the binaries in /bin/ and /sbin/.
- Library filenames are either ld* or lib*.so.*
- Example: ld-2.11.1.so, libncurses.so.5.7
8. /media : Mount points for removable media such as CD-ROMs (appeared in FHS-2.3).
- Temporary mount directory for removable devices.
- Examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer
9. /mnt : Temporarily mounted filesystems.
- Temporary mount directory where sysadmins can mount filesystems.
10. /opt : Optional application software packages.
- Contains add-on applications from individual vendors.
- Add-on applications should be installed under either /opt/ or /opt/ sub-directory.
11. /sbin : Essential system binaries, e.g., fsck, init, route.
- Just like /bin, /sbin also contains binary executables.
- The linux commands located under this directory are used typically by system administrator, for system maintenance purpose.
- Example: iptables, reboot, fdisk, ifconfig, swapon
12. /srv : Site-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems.
- srv stands for service.
- Contains server specific services related data.
- Example, /srv/cvs contains CVS related data.
13. /tmp : Temporary files. Often not preserved between system reboots, and may be severely size restricted.
- Directory that contains temporary files created by system and users.
- Files under this directory are deleted when system is rebooted.
14. /usr : Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications.
15. /proc : Virtual filesystem providing process and kernel information as files. In Linux, corresponds to a procfs mount. Generally automatically generated and populated by the system, on the fly.
- Contains information about system process.
- This is a pseudo filesystem contains information about running process. For example: /proc/
directory contains information about the process with that particular pid. - This is a virtual filesystem with text information about system resources. For example: /proc/uptime
Modern Linux distributions include a /run directory as a temporary filesystem (tmpfs) which stores volatile runtime data, following the FHS version 3.0. According to the FHS version 2.3, such data were stored in /var/run but this was a problem in some cases because this directory is not always available at early boot. As a result, these programs have had to resort to trickery, such as using /dev/.udev, /dev/.mdadm, /dev/.systemd or /dev/.mount directories, even though the device directory isn’t intended for such data.Among other advantages, this makes the system easier to use normally with the root filesystem mounted read-only. For example, below are the changes Debian made in its 2013 Wheezy release:
- /dev/.* ? /run/*
- /dev/shm ? /run/shm
- /dev/shm/* ? /run/*
- /etc/* (writeable files) ? /run/*
- /lib/init/rw ? /run
- /var/lock ? /run/lock
- /var/run ? /run
- /tmp ? /run/tmp
?list=PLqM7alHXFySFc4KtwEZTANgmyJm3NqS_L
This article is contributed by Kishlay Verma. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeek’s main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Источник
Национальная библиотека им. Н. Э. Баумана
Bauman National Library
Персональные инструменты
FHS (File System Hierarchy Standard)
Разработчик | The Linux Foundation |
---|---|
Начальная версия | 14 February 1994 года ; 27 years ago ( 1994-02-14 ) |
Последний релиз |