Types of Files
A Unix file system might hold six different categories of files:
- Regular files
- Directories
- Special files
- Named pipes (FIFO)
- Links
- Symbolic Links
Regular files
A regular file (also known as an ordinary file) holds arbitrary data in zero and more data blocks stored inside a file system. These files might easily hold ASCII text or binary data. Individual applications might store their files in a specific format. There is no structure imposed through the operating system about how a regular file must be formatted.
Data blocks belonging to a regular file might not necessarily reside on the disk in a contiguous order. Moreover, the Unix OS hides this side effect from the user and presents a file as if it were a contiguous stream of bytes; the user required not be concerned with a file's underlying storage structure.
Unix identifies the files through a unique number known as the index node (inode) number. A file has only one inode number, while it might have various filenames. The inode numbers are maintained in a directory file with the associated filenames.
Directory files
Directories are a group of files. For example, a user might require grouping all his project files into one directory. Every directory has a name and each file inside the directory has a filename. Directories are special categories of files because they give mapping among the names of files and the files themselves. As a conclusion, the structure of directories describes the structure of the file system as an overall.
The directory consists of a table holding two fields:
inode number filename (to symbolically reference the inode).
Special Files
Special files do not hold data. Alternatively, they give a mechanism to map physical devices to file names in a file system. Every device supported through the system, involving memory, is related with at least one special file. Special files have related software incorporated into the Kernel known as device drivers.
There are two categories of special files: character-special and block-special. A block-special file is related with a block structured device like as a disk that transfers data to the machine's memory in blocks, classically made up of 512, 1024 bytes. A character-special file is related with any device which is not necessarily blocked structured. Serial devices, Terminals, tape drives, system console are character-special files.
Links
The Unix file system gives a facility for connecting files together with various file names. This facility is known as linking. The main purpose of linking files together is to permit a single program to administer different names. Really only one copy of data is stored in the file system. The connect files share the similar inode number and only a directory entry is made for the file.
Symbolic links
A symbolic link is a data file holding the name of the file to which it is supposed to be linked to. A symbolic link can be build even if the file it is supposed to be linked to do not exist. The benefits of having symbolic link is when the file system has lesser in space but a new software package has to be installed in it, a directory could be made on another file system that is then symbolically linked to the name of the expected installation directory.
Within symbolic links, both a directory entry and new inode are established. In addition, a single data block is reserved for it holding the full pathname of the file it references.
FIFOs (Pipes)
A Pipe is used to join two or more Unix processes together permit the data to flow from one process to another without storing the data on the disk. Pipes file are a special file in which buffers up data received in its input so in which a process that reads from its output receives the data on a FIFO (first-in-first-out basis). No data is related with a pipe special file while it uses up a directory inode and entry.