Linux Command - Linux file types
There are different file types in Linux file system.
File Types
use ls -l
command to check file types. the file type is encoded, “-“ is for “regular file”.
The complete list of file types
- - : regular file
- d : directory
- c : character device file
- b : block device file
- s : local socket file
- p : named pipe
- l : symbolic link
Regular files
Regular file is the most common file type in Linux file system.
1 | ls -l /etc/hosts |
output - this is a regular file!
1 | -rw-r--r-- 1 root root 239 Dec 7 20:34 /etc/hosts |
Directory
Directory is also very common
Demo
1 | cd /tmp |
output
1 | drwxr-xr-x 2 root root 4096 Dec 24 12:42 dir |
Character Device
Users and programs communicate with hardware using character and block device
1 | ls -l /dev/usb |
output
1 | total 0 |
Block Device
Similar to Character Device, common block devices are hard drives, memory.
1 | ls -l /dev/sda |
output
1 | brw-rw---- 1 root disk 8, 0 Dec 24 09:57 /dev/sda |
Local Socket
you can find socker file in /var/run directory.
1 | cd |
output
1 | total 4 |
Named Pipe
named pipes allow communication between two local processes.
create named pipe
1 | mkfifo pipe |
ls -l output
1 | prw-r--r-- 1 xing xing 0 Dec 24 13:53 pipe |
Symbolic links
create symbolic link
1 | ln -s file1 file1.link |
ls -l output
1 | -rw-r--r-- 1 xing xing 0 Dec 24 13:54 file1 |