Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction  
2.
Types of Unix File System
2.1.
Ordinary Files
2.2.
Directories
2.3.
Special Files
2.4.
Pipes
2.5.
Sockets
2.6.
Symbolic Links
3.
Frequently Asked Questions
3.1.
What is a file?
3.2.
What do you mean by Unix?
3.3.
What is block device access?
4.
Conclusion
Last Updated: Mar 27, 2024

UNIX File System

gp-icon
Operating system track
Free guided path
14 chapters
83+ problems
gp-badge
Earn badges and level up
Operating Systems

Introduction  

Unix File System is defined as the framework that organizes and stores a large amount of data that can be handled easily. It consists of elements like a file, a collection of related data that can be viewed logically as a stream of bytes (or characters). A file is also the smallest storage unit in the Unix file system.

In other words, the Unix file system is a methodology for logically analyzing and storing a huge amount of data such that the system is easy to manage.

The file system consists of two main components which are files and directories. The entire file system follows a hierarchy in which directories act as a special file containing multiple files. The highest level directory in the entire hierarchical structure is known as the root. The root is denoted as ' / '. There can be many sub-directories under this directory.

The following diagram explains the hierarchy:

Hierarchy

Some directories and their descriptions are as follows:

  • /bin: short for binaries, this is the directory where many commonly used executable commands reside 
  • /dev: contains device-specific files 
  • /etc: contains system configuration files 
  • /home: contains user directories and files 
  • /lib: contains all library files 
  • /mnt: contains device files related to mounted devices 
  • /proc: contains files related to system processes 
  • /root: the root users' home directory ( note this is different than ‘ / ‘ ) 
  • /sbin: binary files of the system reside here. 
  • /tmp: storage for temporary files that are periodically removed from the file system 
  • /usr: It is the directory holding user home directories, its use has changed, and it also contains executable commands
  • /var: It is a short form for ‘variable’, a place for files that may often change

Also see, File Systems

Check out this article - File System Vs DBMS, Multiprogramming vs Multitasking

Types of Unix File System

The Unix File Systems are classified into six types, that are:

  1. Ordinary Files
  2. Directories
  3. Special Files
  4. Pipes
  5. Sockets
  6. Symbolic Links


Now we will learn these types of Unix file systems in brief. 

Ordinary Files

The files in Unix, which include program instructions, texts, and data, these files are known as ordinary files.

Some of the characteristics of ordinary files are:

  • There are no other files in ordinary files. 
  • They are always placed under the directory file. 
  • These files store the information of users. It may be some text or any image which we have to draw.
  • We mainly work with ordinary files.

Directories

Directories store both kinds of files: special as well as ordinary files. Some of the characteristics of directories are:

  • Directories may contain other directories also.
  • All these directories are the descendants of the root directory.
  • We use directories to organize the collection of files.
  • It doesn’t contain real information like text or images.

Special Files

These files represent physical devices like printers, tape drivers, or a terminal. Some of its characteristics are:

  • Special files represent input/output operations on Linux and Unix systems.
  • There are mainly two special files for every device in the Unix system: block special and character special files.
  • Block special: Using it for device input/output will move the data to the higher fixed-size blocks. This kind of access is also known as block device access.
  • Character Special: This is one character at a time for the terminal devices. However, in the case of disk devices, raw access means reading or writing across an entire section of data blocks that are native to our disk. 

Pipes

Pipes are used to link commands together to store both kinds. The following are the characteristics of pipes:

  • It is a temporary file that only holds the data from one command until another reads it.
  • Unix pipes provide the one-way flow of data.
  • Any command's output is assigned to its next command as an input.

Sockets

The files that enable advanced inter-process communication are called Sockets. It is also known as an inter-process communication socket. Some of the characteristics of sockets are:

  • Unix sockets are used in the framework of client-server applications.
  • It is essentially a data stream, exactly the same as the network stream and network socket, except where each transaction is local to the file system.

Symbolic Links

It is used to reference another file in the system. Characteristics of symbolic links are:

  • It involves a text representation of the path to the file it refers to.
  • To an end-user, a symbolic link will seem to have its name, yet when we need to write or read data to this file, it will reference these tasks to the file it focuses on. 
  • If the source file is deleted or moved to a different location, the symbolic file will not function.

    You can also read about the Multilevel Queue Scheduling.

Must Read Evolution of Operating System

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Frequently Asked Questions

What is a file?

A named collection of related (or maybe typically the same) information that is stored (or recorded) on secondary storage such as optical disks, magnetic disks, etc., is known as a file.
Technically, a file is a sequence of bits, bytes, or lines whose meaning is defined by the creator of that file.

What do you mean by Unix?

Unix is an operating system  (O.S.) that has been applied to the family of multitasking, multi-user computer operating systems. It was developed at the Bell Labs research center in the 1970s. Firstly, it was programmed in assembly language, and then it was again reprogrammed in C language. It is stable and provides a GUI (graphical user interface), which helps provide an easy-to-use environment.

What is block device access?

When we use block special files for device input/output, the data will be moved to the higher fixed-size blocks. This kind of access is also known as block device access.

Conclusion

In this blog, we learn about the Unix file system and how this system handles the files in an organized way. We learn about the hierarchy of the file system with various directories and their sub-directories. Then we learn about some directories and their description; later on, we study the types of Unix file systems with their brief details.

Recommended Reading:

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Previous article
File Systems
Next article
Implementing Directory Management Using Shell Script
Guided path
Free
gridgp-icon
Operating system track
14 chapters
83+ Problems
gp-badge
Earn badges and level up
Live masterclass