Home » Types of Files in Unix

Types of Files in Unix

by Online Tutorials Library

Types of Files in Unix

In Unix operating system, all data is organized into files. Each file is organized into directories, and these directories are organized in a tree-like structure called a file system.

The following are the types of files in Unix:

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

Types of Files in Unix

1. Ordinary Files

Ordinary files are the files in Unix, which includes program instructions, text, and data.

  • In ordinary files, there are no other files.
  • Ordinary files are always placed under the directory file.
  • Ordinary files are used to store our information like the text which we have to write or a picture which we have to draw. This is the kind of the file which we mainly work with.
  • In the long-format output of ls -l, the “-” symbol is used to specified such kind of file.

2. Directory

Directory store both special as well as ordinary files. For the users who are familiar with Mac or Windows operating systems, Unix directories are equivalent to the folders. A directory file includes an entry file for each file and a subdirectory which it houses. If there are 5 files in a directory, then there will be 5 entries in the directory. Every entry comprises of 2 components.

  1. The name of the File.
  2. An inode number, which is a unique identification number for the file or directory.
  • Branching points in the hierarchical tree.
  • We use it to organize the collection of files.
  • It contains special files, ordinary files or other directories.
  • It does not contain “real” information that we would work with, like text. Mostly, only need for organizing files.
  • Each file is descendant of the root directory (named /) located at the tree’s top.

In the long-format output of ls -l, we used the “d” symbol in order to specify this kind of file.

3. Special Files

We use special files to represent the real physical device like terminal, tape drive, and printer. and also used for Input/Output(I/O) operations. Special files or devices are used for Input/Output(I/O) on Linux and Unix systems. They look as similar to the ordinary file or directory in a file system.

Mainly two kinds of special files for every device in the Unix system are there such as block special files and character special files.

  • If we use the block special file for the device input/output (I/O), the data is moved to the higher fixed-size blocks. This kind of access is known as block device access.

This is one character at a time for the terminal devices. However, for disk devices, raw access means reading or writing across an entire section of data-blocks that are native to our disk.

  • In the long-format output of ls -l, using the “c” symbol character distinct, files are marked.
  • In the long-format output of ls -l, using the “b” symbol block, distinct files are marked.

4. Pipes

In Unix, with the help of pipes, we can link command together. Pipes is like a temporary file that only exists to hold the data from one command till it is read by another. A one-way flow of data is provided by the Unix pipe. The first command’s output sequence is used like an input to the next command sequence. In order to create a pipe, the vertical bar (|) has to be placed on the command line between 2 commands. Such as who | wc -l

In the long-format output of ls -l, known as pipes, are marked using the symbol “p.”

5. Sockets

Unix sockets are a type of file that enables for advanced inter-process communication. It is also known as inter-process communication socket. In the framework of the client-server application, a Unix Socket is used. It is essentially a data stream, same as the network stream and network socket, except each transaction is local to the file system.

In the long-format output of ls -l, using the “s” symbol, Unix sockets are marked.

6. Symbolic Link

The symbolic link is used to reference another file in the file system. In order to reference another file of the file system, we use the symbolic link. 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 own name, yet when we need writing or reading data to this file, it will rather reference these tasks to the file it focuses to. When we delete the soft link itself, then the data file would, in any case, be there. The symbolic file will not function if the source file is deleted or moved to the different location.

In the case of the long-format output of ls -l, using the “l” symbol, the symbolic link is marked.


Next TopicLinux Daemon

You may also like