UNIX - Files

December 2016

Introduction to UNIX files

In UNIX systems any element is represented in the form of a file. All files are architectured around a single tree structure where the base, called the root, is written "/".

File types

UNIX systems define different file types:

  • Physical files, entered on the hard disk. This is a file in the generally understood sense of the word;
  • Directories are files (nodes) of the tree structure able to contain files or other directories. A directory contains at least a parent directory (written ..), relating to the directory at the higher level, and a current directory (written .), i.e. itself;
  • Links are special files enabling several names (links) to be associated to a single and same file. This system makes it possible to have several instances of the same file in several places in the tree structure without needing to copy it, which in particular helps to ensure maximum coherence and save on disk space. There are two types of links:
    • Symbolic links representing virtual pointers (shortcuts) to the real files. In the event that a symbolic link is deleted, the file which it points to is not deleted. Symbolic links are created using the In -s command according to the following syntax:
      ln -s name-of-real-file name-of-symbolic-link
    • Physical links (also called hardlinks) represent an alternative name for a file. So, when a file has two physical links, the deletion of one or other of these links does not lead to the deletion of the file. More specifically, while there is at least one physical link remaining, the file is not deleted. On the other hand, when all physical links for the same file are deleted the file is too. Please note however, that it is only possible to create physical links within the single and same file system. Physical links are created using the In (without the option -n) command according to the following syntax:
      ln name-of-real-file name-of-physical-link
  • Virtual files do not really exist because they only exist in the memory. These files, located in particular in the /proc directory contain information about the system (processor, memory, hard disks, processes, etc.);
  • The Device files located in the /dev/ directory relate to the system devices. This concept may be disconcerting for a new user for the first time.

The concept of mount points

Files in a UNIX system are organized into a single tree structure. It is however possible to have several partitions using a mechanism called mounting which makes it possible to connect a partition to a directory in the main tree structure. So, the fact of mounting a partition in the directory /mnt/partition makes all the files in the partition accessible from this directory, called the "mount point".

File hierarchy under Unix

To ensure compatibility and portability, UNIX systems comply with the FHS (File Hierarchy Standard) standard. The basic hierarchy of a Unix system is as follows:

/the root, containing the main directories
/binContains the executables necessary for the system, used by all users.
/bootContains the loading files for the kernel, including the bootstrap loader.
/devContains entry points for the devices.
/etcContains the configuration files required for the administration of the system (files passwd, group, inittab, ld.so.conf, lilo.conf, etc.)
/etc/X11contains specific files for the configuration of X (contains XF86Config, for example)
/homeContains the users' personal directories. Insofar as the directories located under /home are intended to host the user files for the system, you are advised to dedicate a specific partition to the /boot directory in order to limit damage in the case of disk space saturation.
/libContains standard libraries shared between the system's different applications.
/mntMakes it possible to host the mount points of temporary partitions (CD-Rom, floppy disk, etc.)
/procMerges a collection of virtual files making it possible to obtain information about the system or processes being executed.
/rootRoot administrator's personal directory. The administrator's personal directory is located apart from the other personal directories because it is located in the root partition so as to be able to be loaded at the start, before the mounting of the /home partition.
/sbinContains essential system executables (for example the command adduser).
/tmpcontains temporary files
/usrSecondary hierarchy
/usr/X11R6this directory is reserved for system X version 11 release 6
/usr/X386used before by X version 5, this is a symbolic link to /usr/X11R6
/usr/bincontains the majority of binary files and user commands
/usr/includecontains header files for the programs C and C++
/usr/libcontains most of the shared libraries for the system
/usr/localcontains data relating to the programs installed on the local machine by the root
/usr/local/binBinaries for local programs
/usr/local/includeLocal C and C++ header files
/usr/local/libShared local libraries
/usr/local/sbinLocal system binaries
/usr/local/shareIndependent hierarchy
/usr/local/srcLocal source files
/usr/sbincontains binary files not essential for the system that are reserved for the system administrator
/usr/sharereserved for non-dependent data of the architecture
/usr/srccontains source code files
/varcontains changeable data such as database files, logs, files for the print spooler or even waiting emails.

Related :


UNIX: Archivos
UNIX: Archivos
UNIX - Les fichiers
UNIX - Les fichiers
UNIX - I file
UNIX - I file
UNIX - Os arquivos (br) ficheiros (pt)
UNIX - Os arquivos (br) ficheiros (pt)
This document entitled « UNIX - Files » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.