Updated May 31, 2023
Introduction to Unix File System
Unix File System can be defined as a framework that organizes and stores a huge volume of data that can be handled with ease. It involves elements like file which is a collection of related data that can be viewed logically, appears as a stream of bytes, with attributes containing information in relation to the concerned file. The file system consists of two main components, i.e, files and directories. The entire system follows a hierarchy in which directories act as special files thcontainingultiple files, with the highest-level directory in the enerarchical structure being termed as root whmbolically denoted by ‘/’. There can be many subdirectories under this directory.
The Unix Filesystem usually has the below directories present in the file system.
- bin: It is a short form for binary files. This directory stores the commonly used executable commands.
- mnt: This contains information regarding the mounted devices.
- root: This is the root user’s home directory.
- tmp: This is a storage for temporary files. Since they are temporary, the filesystem periodically removes them.
- usr: It contains a set of executable commands
- home: It has a collection of directories and files.
- proc: It contains files that are related to system processes.
What is Unix?
Unix is an operating system that has been applied to the family of multitasking, multiuser computer operating system. It was derived from the AT&T UNIX operating system and was developed in the 1970s at the Bell Labs research center. It was first programmed in assembly language and again reprogrammed in C. It’s stable and provides a graphical user interface which helps in providing an easy to use environment. Unix provides users with different program development tools, electronic communication facilities, and many development tools. With these, it also provides multiple UNIX shells where one interprets your commands, and those are passed to the operating system. It also has a kernel that mediates between the shell and the hardware. Kernels are relatively small and efficient. Unix also offers a dedicated file system that enables the execution of various functions. Let us have a look at the file system.
Types of Unix File Systems
The Unix File System consists of different types of files. Let us have a look at these.
1. Ordinary Files
These files store information of the users, which can be text or images. It is usually located under a directory and contains no other files.
Directories help in organizing the files which are present. The directories can contain ordinary, special, or other directories. All these directories are the descendants of the root directory.
3. Special Files
The special files represent physical devices like a printer, tape driver, or terminal. Unix considers any device to be a file. The terminal is considered a file and functions as a standard input file, used for reading input. This terminal is also the standard output file, the command’s output.
To link commands, Unix provides pipes. The pipe is a temporary file. It also retains data from one command until another command reads it. The output of one command serves as the input to the next command.
File Descriptor and Inode
There is clear segregation between the file’s contents and the information present in the file. All files consist of a sequence of characters except for the device and special files. The required information in the filesystem to handle the files is included in an inode data structure. The inode identifies a file and requires certain attributes to manage kernel and filesystem functions. The attributes are file type, device id, user id of file owner, access rights and file mode, etc.
Additional File Attributes in Unix File System
A file can have some additional attributes, as below.
- Permission modes: It tells the permissions assigned to a file for the owner.
- Owner: This is the owner of the file.
- Group: This specifies the groups associated with that file.
- File Name: It is the name associated with the file.
- Modification date: it was the date when the file was last modified.
- Size: The size of a file in bytes is specified.
- Number of links: The files which relate to a particular file.
File and Directory Commands in Unix File System
Unix provides many commands that assist in working with files. Here are a few of these commands listed below.
1. ls: It lists all files in a particular directory.
It has a few variations below.
- ls dir: Shows the contents present in a directory.
- ls a: It shows all files, including the hidden files.
- ls -al: It gives a detailed listing of all file contents.
2. Less: It displays less number of lines rather than the complete file.
3. Head: It displays the file’s first few lines or n lines.
4. Tail: Displays the file’s last few lines or n lines.
5. Cat: It displays the contents of the entire file without the pagination of the file.
6. cp: It copies the contents of one file to another. It overwrites the contents of the file if not mentioned otherwise.
7. mv: It moves the specified files to the specified destination.
8. rm: Removes or deletes the specified files.
Unix is an operating system that handles files in an organized way. With all the commands and functions, managing files is very easy. It also has permissions that limit access to the files. Only authorized people can access the files and perform different operations. It also has different kinds of files segregated, which makes it easier to use. Therefore, Unix’s file system earns its reputation as one of the most user-friendly file systems.
We hope that this EDUCBA information on the “Unix File System” was beneficial to you. You can view EDUCBA’s recommended articles for more information.