Understanding the different file types in Linux

Ever wondered why you see different colors when you do ls in linux?
In this post I'll show you what each color stands for. 

In the screenshot below, I did ls -l which will show extra details - file type, file permission, file owner, owner's group, date of creation/modification and file name.
'Cos I did this on my android phone which runs a stripped version of Bash shell, the colors aren't showing. If you do this on a Linux PC, the file names will be colored differently.

Linux has 6 file types, and everything in Linux is referred to as a file - directories/folders, devices, even system processes.
•Ordinary files: These are regular files. (white/black)
•Directories: These are files that contains other files and directories, and provide pointers to them. (blue)
•Symbolic links: These special files link to another file, in a different location. (Cyan)
•Block and character device files: All physical devices in Linux are represented by device files. e.g. /dev/sda (yellow)
•Socket file: Provides protected inter-process networking. (Purple)
•Named Pipe file: Like socket files but doesn’t use network socket semantics. (Red)
•$ ls –l indicates all these types
– -rw-r--r--   ordinary file
–brw-rw----   block device file
–crw-rw-rw-  character device file
–drwxr-xr-x  directory file
–lrwxrwxrwx  symbolic file
–srw-rw-rw-  socket file
–prw-rw-rw-  named pipe file


Post a Comment

Follow me on Twitter | About me | Terms of Service | Privacy Policy