File Types in Unix Based OSs
May 5, 2025
There are 7 types of files in a UNIX like environment:
- Regular File
- Directories
- Character device files
- Block device files
- Local domain sockets
- Named pipes(FIFOs)
- Symbolic links
Determining File Types using ls
You can determine the file type of an existing file with ls -ld
- The flag
-ldisplays detailed information about the file or directory like permission, number of links, owner, group, size etc. - Flag
-dprevents ls from listing the content of directories, instead it shows the information about the directory itself. For example:
File Type encoding Used by ls
| File Type | Symbol |
|---|---|
| Regular file | - |
| Directory | d |
| Character device file | c |
| Block device file | b |
| Local domain socket | s |
| Name pipe | p |
| Symbolic link | l |
Regular Files
- Regular files consist of a series of bytes.
- The filesystems impose no structure on their contents.
- Both sequential and random access is allowed.
- Example: Text files, data files, executable programs and shared libraries.
Directories
- A directory contains named references to other files.
mkdirandrmdiris used to create and delete directories respectively.- The special entries
.and..refer to the directory itself and its parent directory. - A file's name is stored within its parent directory, not with the file itself.
- More than one file inside a directory