File system hierarchy standard

from Wikipedia, the free encyclopedia
File system hierarchy standard

Screenshot
Example of a standard root directory
Basic data

Maintainer Linux Foundation
developer LSB working group
Current  version 3
(June 2015)
operating system Linux
German speaking No
refspecs.linuxfoundation.org/fhs

The Filesystem Hierarchy Standard ( FHS ) is a guideline for the directory structure under Unix-like operating systems .

The standard is aimed at software developers , system integrators and system administrators . Its purpose is to promote the interoperability of computer programs by making the location of directories and files predictable.

The development of this guideline began in August 1993 and was initially only related to Linux . In the meantime, some of the FreeBSD developers have helped create a comprehensive standard for all Unix-like systems. This collaboration was officially discontinued in May 2011 after the Linux Foundation took over the project. Currently, this standard is only used by Linux distributions . The first documentation of such a hierarchy appeared in AT&T UNIX Version 7.

File categories

The FHS differentiates files under two aspects:

  • "Static" or "variable"
“Static” are those files that do not change without the intervention of a system administrator. All other files are considered "variables".
  • "Shareable" or "unshareable"
"Shareable" are those files that can be used by other computers via a computer network. All other files are considered "unshareable".

Four categories of files result from these two aspects:

  • "Static shareable"
  • "Static unshareable"
  • "Variable shareable"
  • "Variable unshareable"

In order to make data backups and provision in the computer network more efficient, the FHS does not plan to save files of different categories in the same directory. Historically, this separation did not exist.

Root directory

The partition ( volume ) of the root directory must contain all the files that are necessary to start up the operating system and to integrate further partitions. In order to be able to repair a system, it must also contain the necessary tools.

In order to increase flexibility and reliability, the FHS recommends creating parts of the directory structure in other partitions. Additional partitions are transparent under Unix and similar operating systems .

Main directories

14 directories or symbolic links to directories are required in the root directory:

/ am Basic command binaries historical: "utility programs" (programs such as assembler and compiler )
/boat static files of the boot loader historical: -
/ dev Device files historical: "devices" (devices such as hard drives and system console )
/Etc Host- specific system configuration historically: "essential data and dangerous maintenance utilities" (essential data and dangerous maintenance programs such as init and passwd )
/ lib basic dynamic libraries and kernel modules historical: "object libraries and other stuff" (object libraries and other material)
/ media Mount point for removable media historical: -
/ mnt for temporarily mounted file system historical: -
/ opt additional application programs historical: -
/run data relevant to ongoing processes historical: -
/ sbin essential binaries of the system historical: -
/ srv Data for services historical: -
/ tmp temporary data historical: "temporary files" (temporary files, usually on a fast device)
/ usr secondary hierarchy historically: "general-purpose directory" (universal directory, usually the mount point of another file system)
/ var variable data historical: -

The directories / opt, / usr and / var are designed so that they do not have to be in the partition of the root directory.

Additional directories are required if appropriate subsystems are installed:

/ home User directories
/ root Directory of the root account
/ lib ... alternative dynamic libraries, e.g. / lib32 and / lib64 for 32-bit and 64-bit

Other directories should not be created in the root directory. Application programs should not request or create files in the root directory.

/ bin - basic system commands (for all users)

/ bin contains all commands that can be called by both the administrator and the user and are also required when no other file systems are mounted, for example in single user mode. In addition, scripts that use such commands can also be stored there.

The / bin directory must not contain any subdirectories. The following programs or symbolic links to the Unix commands are at least required in / bin:

  • cat: Append files together ( English: con cat enate ) and write to standard output (stdout)
  • chgrp : change group membership ( English: ch ange gr ou p )
  • chmod : Change the file access rights ( English: ch ange mod e )
  • chown : change owner and group membership ( English: ch ange own ership )
  • cp : Copying files or directories ( English: c o p y )
  • date: Show or set the system date and time
  • dd : converting or copying data ( English: d ump d ata )
  • df: Show the free disk space ( in English: d isk f rees pace )
  • dmesg: Show or configure the ring buffer of the kernel ( English: d isplay mes sa g es )
  • echo : Play a line of text
  • false : Generating an error status code
  • hostname : Show or set the current computer name
  • kill : kill a process
  • ln : setting links between files ( English: l i n k )
  • login: check user identity and start user interface
  • ls : show directory contents ( English: l i s t )
  • mkdir: creating a directory ( English: m a k e dir ectory )
  • mknod: creating special device files ( English: m a k e nod e )
  • more : show data scrolling page by page
  • mount: mounting of file systems
  • mv : moving or renaming files ( English: m o v e )
  • ps : show process status ( English: p rocess s tatus )
  • pwd : Show the name of the current directory ( English: p rint w orking d irectory )
  • rm : deleting files or directories ( English: r e m ove )
  • rmdir: delete empty directories ( English: r e m ove you ectory )
  • sed : Editing of data without interaction ( English: s tream ed itor )
  • sh : Unix shell ( command line interpreter , English: sh ell ). If sh is not the original Bourne shell , sh must bea hard or soft link to the shell used.
  • stty: Show or set settings of a data terminal device ( English: s et t ele ty per )
  • su : starts a user interface with a new user identity ( English: s ubstitute u ser )
  • sync: Writing the contents of data buffers to the data carrier ( English: sync hronize )
  • true : Generate a success status code
  • umount: Unmount filesystems ( English: u n mount )
  • uname : Show various system information ( English: U NIX name )

If required, the following commands (or links to them) must also be installed in the / bin directory:

  • csh : C -like command line interpreter ( English: c -like sh ell )
  • ed : Editing of text ( English: ed it )
  • tar : Management of file archives ( English: t ape ar chiver )
  • cpio : Copying files to or from archives ( English: c o p y i nput / o utput )
  • gzip : Compression of data ( English: G NU zip )
  • gunzip : Decompress data (mostly as a link to gzip)
  • zcat: decompress and display data ( English: z ipped con cat enation )
  • netstat : Show network status information ( English: net work stat us )
  • ping : Sending and receiving data packets via ICMP

All other commands that are required for recovery, such as ftp , tftp or various archiving programs , also have their place here.

/ boot - static files of the boot loader

This directory contains all files required by the boot loader for the boot process. This includes e.g. B. also saved master boot records . The operating system kernel must also be stored either in this directory or in the root directory.

/ dev - device files

The dev contains special files directory / (special file) or device files (device file) . Some of the device files have to be created manually. In this case, the directory must contain the command MAKEDEV or MAKEDEV.local, which can create these device files using the existing hardware.
Worth mentioning are / dev / null , which can be written to but everything is discarded, / dev / zero , from which
zero bytes can be read in any amount, and / dev / random (or / dev / urandom), which is used as hardware -Random generator is used.

udev has replaced devfs since Kernel 2.6 and now uses configuration files (by default in / etc / udev ) in the user space to automatically create the devices in / dev.

/ etc - specific configuration files

/ etc originally stood for "everything else" (lat. et cetera ). However, it has then established itself as a configuration directory and is therefore often interpreted as an "editable text configuration". The / etc directory and its subdirectories contain all kinds of configuration files . These files must be static files (see above). There must be no binary files in this directory.

The following subdirectories can be: a. exist in / etc:

/ etc / opt
Configuration for programs in / opt: System-specific configuration files for additionally installed software packages must be installed in this directory in the appropriate subdirectories (/ etc / opt / < subdirectory > ). There is no regulation on how the / etc / opt directory is divided.
/ etc / X11
Configuration of the X Window System , optional: All configuration files of the X11 system are stored in this directory. The directory is particularly home to the files Xconfig, xorg.conf and Xmodmap (if available). If a window manager has more than one configuration file, a separate subdirectory can be created for this, otherwise the configuration file is saved directly in the / etc / X11 directory with the file name <WindowManager> .wmrc.
/ etc / sgml
Configuration for SGML , optional: SGML systems (if available) save basic configurations in this directory . Files with the extension .conf designate conventional configuration files, files with the extension .cat provide special DTD catalogs with references to other catalogs.
/ etc / xml
Configuration for XML , optional: The basic settings of any existing XML systems are installed in this directory . Configuration files have the file extension .conf , a DTD catalog is located in the catalog file .
/ etc / mc
Configuration for Midnight Commander , optional
/ etc / network
In Debian it contains configuration files that affect the network

In general, the configurations of individual services are located in / etc / <service name> / and / or /etc/<service name>.conf (the LDAP under the Debian derivative Ubuntu, for example, does both without a clear file name). With daemons the final d is often missing , the NTP server z. B. has the process ntpd , but the configuration file /etc/ntp.conf .

The following configuration files definitely belong in / etc (if available):

csh.login
system-wide initialization file for the C-like command interpreter
exports
Access rights for NFS shares
fstab
Table with static information about mountable file systems
ftpusers
Contains the names of the users to be excluded from the ftp call
gateways
static information about the gateways available in the network
gettydefs
Parameters for the transmission speed and other settings of the terminals
group
Line by line information on the entered user groups
host.conf
Configuration data for name resolution
hosts
static information on the assignment of computer names to IP addresses
hosts.allow
Access permissions for the tcpd TCP wrapper
hosts.deny
Exclusion criteria for the TCP wrapper tcpd
hosts.equiv
approved computers for rlogin , rsh , rcp
hosts.lpd
approved computers for the printing service lpd
inetd.conf
Configuration file for the Internet super server inetd
inittab
Configuration file for the initialization process init
issue
System identification file for the output of information before the login process
issue.net
System identification file for the output of information before the login process via the network ( e.g. telnet )
ld.so.conf
List of directories with libraries to be dynamically integrated
motd
Notification of the day to be issued after the registration process ( m essage o f t he d ay)
mtab
dynamically generated information about the mounted file systems
mtools.conf
Configuration file for mtools
the command for editing MS-DOS file systems
networks
static information about the available networks
passwd
Contains the user name, description of the user, group ID, user ID, the home directory and the login command (usually a shell). In the past, this file also contained the user password. This is now stored in / etc / shadow.
printcap
Configuration file for the print service lpd
profile
system-wide configuration file for the login process using sh
protocols
List of IP protocol IDs and numbers
resolv.conf
Configuration file for name resolution
rpc
List of RPC protocol identifiers
securetty
Access authorizations for remote logons
services
List of port IDs for individual services
shadow
encrypted passwords of the users and the period of validity
shells
full names of the permitted command interpreters
syslog.conf
Configuration file for the system log service syslogd

/ home - home directories, optional

This directory structure is used to hold the user-specific data of the individual users of the system. The FHS only lists this directory as optional, although it is established as a quasi-standard. All user-specific configuration files are stored in hidden files and directories (which have a dot as the first character of the file name) under / home / $ USER / . These hidden files and directories in the user directory are often called "dot files".

/ lib - kernel modules and dynamic libraries

The / lib directory contains the installed dynamic libraries and kernel modules that are required to start the system and for the programs in / bin and / sbin. The dynamic C standard library libc.so. * and the linker library ld * are also located here . The modules subdirectory contains the above-mentioned kernel modules if they are installed.

/ lib <nr> - Alternative kernel modules and dynamic libraries

Some systems support multiple binary formats (for different processor architectures or modes), each with its own version of the same library. Then there are, for example, / lib32 and / lib64 for the two operating modes (32-bit and 64-bit) of the x86 processor.

/ media - mount points for removable media

The individual subdirectories in / media serve as a mount point for every type of removable medium. Earlier portable media was / mnt either directly in the root directory or in mounted . In order to streamline the root directory, the directories were moved to the / media folder. The standard provides the following optional subdirectories:

/ media / floppy
diskette
/ media / cdrom
CD-ROM
/ media / cdrecorder
CD burner
/ media / zip
Zip drive

If a device is present several times, appending a number to the device type is suggested.

/ mnt - temporary mount points for file systems

The directory is used for temporary mounting of foreign file systems of all kinds. Installation programs are expressly prohibited from using the / mnt directory for temporary files.

/ opt - additional software packages

The directory is for all optional, i. H. additionally installed software provided that does not come from the package sources belonging to the distribution. The packages must be in a subdirectory named/ opt / <package> or / opt / <manufacturer> be installed, where <package> is a descriptive package name and <manufacturer>is the name of the manufacturer registered with LANANA . The subdirectories/ opt / bin, / opt / doc, / opt / include, / opt / info, / opt / lib, and / opt / manare reserved for the local system administrator. Software package binaries are usually found only in/ opt / <package> / bin

/ root - user directory for user root, optional

The directory can form the user directory for the user root. This directory is only a recommendation by the FHS.

/ run directory

At the end of March 2011, the developers of the Linux distribution Fedora announced that future Fedora versions would contain the directory / run. Its function is to replace the / var / run directory and solve the problem that under certain circumstances / var / run is not yet available during the boot process, but is required for booting. Several Linux distributions have given their support. / run is now also required by the file system hierarchy standard.

/ sbin - important system commands

The directory contains commands for system administration and other tasks that only the root user can perform. These are essentially all commands that could have been placed in the / bin directory, but e.g. B. for reasons of storage space not there. Programs expected in / sbin: shutdown, fastboot, fasthalt, fdisk, fsck, fsck. *, Getty, halt, ifconfig, init, mkfs, mkfs. *, Mkswap, reboot, route, swapon, swapoff, update

/ srv - data offered by services

The data on the services offered should be stored in this directory. At the moment there are no regulations on how the directory structure in / srv should look. One suggested option is to name the subdirectories after the service, e.g. B. www, ftp, mysql, etc. Another possibility is to organize according to administrative units such as student councils at universities. This is currently only done by SuSE and Arch Linux. For example, the directory / var / www exists under Debian, whereas SuSE uses / srv / www (Arch: / srv / http).

/ tmp - temporary files

This directory must exist because there are programs that save their temporary files in this directory. This directory was included in the FHS primarily because of its historical significance. The directory is approved for writing by all users and must have a sticky bit .

/ usr directory structure

/ usr ( U nix S ystem R esources, originally: US e R ) is the second important level of the file system. This area can be used jointly by several computers (shareable) and accordingly does not contain any content that is dependent on the local computer or that varies over time. These are stored in other places in the file system.

The following directories must exist in / usr:

/ usr / bin
many user commands
This is the primary directory for the system's executable files.
/ usr / include
Header files are integrated by programs
The header files contain the various include files with prototype definitions.
/ usr / lib
Libraries
Modular program code that is shared by different programs.
/ usr / local
Distribution-independent local hierarchy. The local system administration can and should store programs and data here that have been installed independently of the corresponding distribution of the respective system, such as self-compiled programs and files or programs and files downloaded independently of the distribution. The installation mechanisms of the distribution in question are expressly prohibited from touching this directory structure. The design of the internal structure of / usr / local is the responsibility of the local system administration and is not specified by the FHS.
/ usr / sbin
further, not mandatory system commands
In contrast to / sbin, these system commands are not used by the administrator during the boot process.
/ usr / share (architecture independent data)

In addition, the following directories can optionally exist:

/ usr / X11R6
X Window System , Version 11 Release 6
/ usr / games
Games
/ usr / lib <nr>
alternative versions of dynamic libraries
/ usr / src
Source code

To ensure compatibility with older systems, symbolic links can be created for the following directories:

  • / usr / spool → / var / spool
  • / usr / tmp → / var / tmp
  • / usr / spool / locks → / var / lock

/ var directory structure

The / var directory (English var iable ) contains variable data that arise in the course of processing. The following directories, or symbolic links to directories, are expected in / var:

/ var / cache
data cached by application programs
/ var / lib
variable status information
/ var / local
variable data related to / usr / local
/ var / lock
Directory for lock files for process synchronization
/ var / log
Directory for log files
/ var / opt
variable data in connection with / opt
/ var / run
Data that are important for running processes (/ run now fulfills the function; the directory exists to ensure compatibility with systems and software that use an older version of the FHS specification and can be implemented as a symbolic link on / run)
/ var / spool
Directory for queues to be processed (print jobs, e-mail dispatch jobs ...)
/ var / tmp
temporary files that are retained after a restart

For "historical" reasons, the following directories still exist if required:

  • / var / backups
  • / var / cron (nowadays found under / var / spool / cron)
  • / var / msgs
  • / var / preserve

If the corresponding applications are installed, the following directories are also used:

/ var / account
Process accounting data
/ var / crash
System dumps in the event of a computer crash
/ var / games
variable game dates
/ var / mail
User mailbox files (often as a symlink to / var / spool / mail)
/ var / yp
Network Information Service database files

See also

Web links

Individual evidence

  1. ^ Background of the FHS . In: Filesystem Hierarchy Standard 2.3 . Retrieved January 11, 2011.
  2. Filesystem Hierarchy Standard (FHS) and FreeBSD . freebsd.org. May 10, 2011. Retrieved February 27, 2016.
  3. Re: Filesystem Hierarchy Standard (FHS) and NetBSD . netbsd.org. May 10, 2011. Retrieved February 27, 2016.
  4. Filesystem Hierarchy Standard (FHS) and OpenBSD . nabble.com. May 10, 2011. Retrieved February 27, 2016.
  5. here - layout of file systems . In: FreeBSD Man Pages . FreeBSD Foundation . Retrieved October 3, 2016.
  6. ^ The File System . In: Filesystem Hierarchy Standard 2.3 . Retrieved January 11, 2011.
  7. Requirements . In: Filesystem Hierarchy Standard . Retrieved October 3, 2016.
  8. a b c d e f here - file system hierarchy . In: FreeBSD Man Pages - Unix Seventh Edition . FreeBSD Foundation. Retrieved October 3, 2016.
  9. Specific Options . In: Filesystem Hierarchy Standard 2.3 . Retrieved January 11, 2011.
  10. What's this / run directory doing on my system and where does it come from? . fedoraproject.org. March 30, 2011. Retrieved February 27, 2016.
  11. Distributions introduce new directory / run . In: Pro-Linux . March 31, 2011. Accessed February 27, 2016.