Unix filesystem

From Wikipedia, the free encyclopedia
An Example of a Unix-like Root Filesystem

In Unix and operating systems inspired by it, the file system is considered a central component of the operating system.[1] It was also one of the first parts of the system to be designed and implemented by Ken Thompson in 1969. Like in other operating systems, it provides information storage and interprocess communication, in the sense that the many small programs that traditionally comprise a Unix system can store information in files so that other programs can read these, although pipes complemented it in this role starting with the Third Edition.

The rest of this article uses "Unix" as a generic name to refer to both the original Unix operating system as well as its many workalikes.

Principles

The original Unix file system supported three types of files: ordinary files, directories, and "special files", also known as device files.[1] The Berkeley Software Distribution added sockets and symbolic links to this, and modern Unix system may support additional types of files.<ref name="43bsd>Leffler, Samuel J.; Marshall Kirk McKusick, Michael J. Karels and John S. Quarterman (October 1989). The Design and Implementation of the 4.3BSD UNIX Operating System. Addison-Wesley. ISBN 0-201-06196-1.  </ref> The filesystem appears as a single rooted tree of directories.[1] Instead of addressing separate volumes such as disk partitions, removable media, and network shares as separate trees (as done in MS-DOS and Windows: each "drive" has a drive letter that denotes the root of its file system tree), such volumes can be "mounted" on a directory, causing the volume's file system tree to appear as that directory in the larger tree.[1] The root of the entire tree is denoted /.

In the original Bell Labs Unix, a two-disk setup was customary, where the first disk contained startup programs, while the second contained users' files and programs. This second disk was mounted at the empty directory named usr on the first disk, causing the two disks to appear as one filesystem, with the second's disks contents viewable at /usr.

Unix directories do not "contain" files. Instead, they contain the names of files paired with references to so-called inodes, which in turn contain both the file and its metadata (owner, permissions, time of last access, etc., but no name). Multiple names in the file system may refer to the same file, a feature known as (hard) linking.[1] (If this feature is taken into account, the file system is a limited type of directed acyclic graph rather than a tree. As originally envisioned ca. 1968-69, the file system would in fact be a more general type of directed graph, but navigating this turned out to be difficult, and the decision was made to disallow multiple links to a single directory, enforcing a tree structure.)

Conventional directory layout

Certain conventions exist for locating particular kinds of files, such as programs, system configuration files and users' home directories. These were first documented in the hier(7) man page since Version 7 Unix;[2] subsequent versions, derivatives and clones typically have a similar man page.[3][4][5][6][7]

The details of the directory layout have varied over time. Although the file system layout is not part of the Single UNIX Specification, several attempts exist to standardize it, such as the Linux Foundation's Filesystem Hierarchy Standard (FHS).

Here is a generalized overview of common locations of files on a Unix operating system:

Directory or file Description
/ The slash / character alone denotes the root of the filesystem tree.
/bin
Stands for "binaries" and contains certain fundamental utilities, such as ls or cp, which are generally needed by all users.
/boot
Contains all the files that are required for successful booting process.
/dev
Stands for "devices". Contains file representations of peripheral devices and pseudo-devices.
/etc
Contains system-wide configuration files and system databases. Originally also contained "dangerous maintenance utilities" such as init,[8] but these have typically been moved to /sbin or elsewhere.
/home
Contains the home directories for the users. In the original version of Unix, home directories were in /usr instead.[9] Some systems use or have used different locations still: OS X has home directories in /Users, and older versions of BSD put them in /u.
/lib
Contains system libraries, and some critical files such as kernel modules or device drivers.
/lib64
Contains system libraries, and some critical files such as kernel modules or device drivers, on some 64-bit systems.
/media
Default mount point for removable devices, such as USB sticks, media players, etc.
/mnt
Stands for "mount". Contains filesystem mount points. These are used, for example, if the system uses multiple hard disks or hard disk partitions. It is also often used for remote (network) filesystems, CD-ROM/DVD drives, and so on.
/opt
Contains locally installed software. Originated in System V, which has a package manager that installs software to this directory (one subdirectory per package).[10]
/proc
procfs virtual filesystem showing information about processes as files.
/root
The home directory for the superuser "root" - that is, the system administrator. This account's home directory is usually on the initial filesystem, and hence not in /home (which may be a mount point for another filesystem) in case specific maintenance needs to be performed, during which other filesystems are not available. Such a case could occur, for example, if a hard disk drive suffers physical failures and cannot be properly mounted.
/sbin
Stands for "system (or superuser) binaries" and contains fundamental utilities, such as init, usually needed to start, maintain and recover the system.
/srv
Server data (data for services provided by system).
/sys
In some Linux distributions, contains a sysfs virtual filesystem, containing information related to hardware and the operating system. On BSD systems, commonly a symlink to the kernel sources in /usr/src/sys.
/tmp
A place for temporary files. Many systems clear this directory upon startup; it might have tmpfs mounted atop it, in which case its contents do not survive a reboot, or it might be explicitly cleared by a startup script at boot time.
/usr
Originally the directory holding user home directories,[9] its use has changed. It now holds executables, libraries, and shared resources that are not system critical, like the X Window System, KDE, Perl, etc. However, on some Unix systems, some user accounts may still have a home directory that is a direct subdirectory of /usr, such as the default in Minix. (on modern systems, these user accounts are often related to server or system use, and not directly used by a person)
/usr/bin
This directory stores all binary programs distributed with the operating system not residing in /bin, /sbin or (rarely) /etc.
/usr/include
Stores the development headers used throughout the system. Header files are mostly used by the #include directive in C programming language, which historically is how the name of this directory was chosen.
/usr/lib
Stores the required libraries and data files for programs stored within /usr or elsewhere.
/usr/libexec
On BSD systems[2] and older distributions of Linux, programs that are meant to be executed by other programs rather than by users directly. E.g., the Sendmail executable may be found in this directory.[11] Not present in the FHS; Linux distributions have typically moved the contents of this directory into /usr/lib, where they also resided in 4.3BSD.
/usr/local
Resembles /usr in structure, but its subdirectories are used for additions not part of the operating system distribution, such as custom programs or files from a BSD Ports collection. Usually has subdirectories such as /usr/local/lib or /usr/local/bin.
/var
A short for "variable." A place for files that may change often - especially in size, for example e-mail sent to users on the system, or process-ID lock files.
/var/log
Contains system log files.
/var/mail
The place where all the incoming mails are stored. Users (other than root) can access their own mail only. Often, this directory is a symbolic link to /var/spool/mail.
/var/spool
Spool directory. Contains print jobs, mail spools and other queued tasks.
/var/tmp
A place for temporary files which should be preserved between system reboots.

References

  • This article incorporates material from the Citizendium article "Unix filesystem", which is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License but not under the GFDL.
  1. 1.0 1.1 1.2 1.3 1.4 Ritchie, D.M.; Thompson, K. (July 1978). "The UNIX Time-Sharing System". Bell System Tech. J. (USA: AT&T) 57 (6): 1905–1929. Retrieved 14 September 2013. 
  2. 2.0 2.1 "hier(7) man page for OpenBSD". Retrieved 14 September 2013. 
  3. "hier(7) man page for FreeBSD". 
  4. "hier(7) man page for 2.9.1 BSD". 
  5. "hier(7) man page for ULTRIX 4.2". 
  6. "hier(7) man page for SunOS 4.1.3". 
  7. "hier(7) man page for Linux". 
  8. hier(7) in the Seventh Edition Unix manual.
  9. 9.0 9.1 Ritchie, Dennis. "Unix Notes from 1972". Retrieved 4 October 2012. 
  10. System V Application Binary Interface Edition 4.1 (1997-03-18)
  11. "Chapter 7. sendmail". UNICOS/mp Networking Facilities Administration. Cray. Retrieved 14 September 2013. 
This article is issued from Wikipedia. The text is available under the Creative Commons Attribution/Share Alike; additional terms may apply for the media files.