“On a UNIX system, everything is a file; if something is not a file, it is a process.”
This statement is true because there are special files that are more than just files (named pipes and sockets, for instance), but to keep things simple, saying that everything is a file is an acceptable generalization.
At the very top of the file system is single directory called “root” which is represented by a / (slash). All other files are “descendents” of root.
File Types Of Unix :
In general, there are 6 file types in Unix system. Below I will give a very short description of each :
- Ordinary Or Regular Files
- Device (Special) Files
- Symbolic Links
- Named Pipe
1.Ordinary Or Regular Files –
This is the most common type of a file in Unix. A large majority of the files found on UNIX and Linux systems are ordinary files. Ordinary files contain ASCII (human-readable) text, executable program binaries, program data, and more. There’s nothing mysterious about this type. Most of the files you will ever work with are regular.
2. Directories –
A directory is a binary file used to track and locate other files and directories. The binary format is used so that directories containing large numbers of filenames can be search quickly.You don’t work with directories directly, instead you manage them with standard commands provided with your OS. The whole directory structure of your Unix system is made of such special files with directory content in each of them.
3. Device (Special) Files :
Device or special files are used for device I/O on UNIX and Linux systems. They appear in a file system just like an ordinary file or a directory.On UNIX systems there are two flavors of special files for each device, character special files and block special files. Linux systems only provide one special file for each device.
When a character special file is used for device I/O, data is transferred one character at a time. This type of access is called raw device access.
When a block special file is used for device I/O, data is transferred in large fixed-size blocks. This type of access is called block device access.
4. Symbolic Link :
Link is yet another file type in Unix, used for referencing some other file of the filesystem.
A link is a tool used for having multiple filenames that reference a single file on a physical disk. They appear in a file system just like an ordinary file or a directory.Like special files, links also come in two different flavors. There are hard links and symbolic links.
Hard links do not actually link to the original file. Instead they maintain their own copy of the original file’s attributes (i.e. location on disk, file access permissions, etc.). If the original file is deleted, its data can still be accessed using the hard link.
On the other hand, symbolic links contain a pointer, or pathname, to the original file. If the original file is deleted, its data can no longer be accessed using the symbolic link, and the link is then considered to be a stale link.
5. Named Pipe :
UNIX allows you to link commands together using a pipe. The pipe acts a temporary file which only exists to hold data from one command until it is read by another.This type of communication is known as inter process communication, or IPC for short.
6. Socket :
A special file type, similar to TCP/IP sockets, providing inter-process networking protected by the file system’s access control. In essence, it is a stream of data, very similar to network stream (and network sockets), but all the transactions are local to the filesystem.
The difference between sockets and pipes is that sockets will facilitate communication between processes running on different systems, or over the network.
That’s it for this post folks!! Hope this post will give you a better idea of what are the file types available in Unix system.