Unix File System

What is file system?

  • A file system consist, a group of methods and data structures tied together to keep track of files/directories on disk or on a disk partition.
  • To provide information storage and retrieval every OS keeps metadata about each file in an organized way.

Unix File System

  • The Unix file system is a tree based hierarchical structure where the root node of this hierarchy is “/”.
  • Almost everything happens in Unix via a file (disk file, device file, etc)
  • Unix filesystem is a directed acyclic graph
  • Directories do not contain actual files. Each directory contains the “file name: inode reference” pairs.
  • The inode contains actual file and the file metadata.

unix filesystem

 

Unix File Types

The Unix OS internal point of view there is an only one type of file whereas to support external applications Unix has provided various special file types.

  • Regular file – These files are regular files. This type of file will have ‘-‘ as the first letter of permission string.
  • Special Files – These files will have non-hyphen value for ls -l output.
    • Directory – This is the most common special file. This type of file will have ‘d’ as the first letter of permission string.
    • Symbolic link – This type of files are the reference to another file. This type of file will have ‘l’ as the first letter of permission string. 
    • Named pipe – These pipes connect the output of one process to the input of another process (inter-process communication). Named pipe are uni directional. This type of file will have ‘p’ as the first letter of permission string.
    • Socket – These files are bi directional inter-process communication special files. This type of file will have ‘s’ as the first letter of permission string. 
    • Device file – These files are used for mounting hardware devices. This type of file will have ‘b’ as the first letter of permission string. 
    • Door – A door is a special file for inter-process communication over the network (a client and server), which is only available on Solaris. This type of file will have ‘D’ as the first letter of permission string. 

 

Unix Directory Structure

  • / – Denotes the root of the filesystem tree.
  • /bin – It contains binaries files and fundamental utilities
  • /boot – It contains files related to booting process.
  • /dev – It contains files of peripheral devices.
  • /etc – It contains configuration files
  • /home – It contains all user directories.
  • /lib – it contains C libraries, etc
  • /media – This is the location for mounting removable devices
  • /mnt – Another mount location for system admins.
  • /opt – Software installation location.
  • /proc – Contains information about processes as files.
  • /root – Superuser’s home directory.
  • /tmp -A temporary files location.