The Linux Concept Journey — Linux File Types

Shlomi Boutnaru, Ph.D.
1 min readJun 1, 2024

--

As we know the philosophy of Linux is that “Everything is a file”. However, not all files are created equally. We have 7 different file types: directory, regular file, named pipe, socket, symbolic link, block device file and character device file (https://linuxconfig.org/identifying-file-types-in-linux) — more information about each type in future writeups.

Overall, we can identify the type of a file using the “ls” utility using the “-l” argument (https://man7.org/linux/man-pages/man1/ls.1.html). The first character in each line identifies the type of the file — as described in the table below (https://www.2daygeek.com/wp-content/uploads/2019/01/find-identify-file-types-in-linux-4.png ).

Lastly, we can display only specific file types by filtering the output of “ls” using “grep” (https://man7.org/linux/man-pages/man1/grep.1.html). For example if we want to see all regular files in the current directory we can use the following one-liner: “ls -la | grep ^-” (https://www.2daygeek.com/find-identify-file-types-in-linux/).

See you in my next writeup ;-) You can follow me on twitter — @boutnaru (https://twitter.com/boutnaru). Also, you can read my other writeups on medium — https://medium.com/@boutnaru. You can find my free eBooks at https://TheLearningJourneyEbooks.com.

https://www.2daygeek.com/wp-content/uploads/2019/01/find-identify-file-types-in-linux-4.png

--

--