The Linux Concept Journey — Directory File

Shlomi Boutnaru, Ph.D.
2 min readJul 4, 2024

--

As you know there are seven different file types used in Linux (https://medium.com/@boutnaru/the-linux-concept-journey-linux-file-types-4cb622887331). Among them we have a “directory” file type, we can think about it as a “file” that holds in its content file names and there representing inode numbers (https://medium.com/@boutnaru/linux-what-is-an-inode-7ba47a519940).

Thus, using the “rm” utility (https://linux.die.net/man/1/rm) basically removes the file from the directory and does not delete it (until the reference count equals “0”). Also, because of that removing a file does not require any permissions on the file itself, it requires having “write permissions” to the directory containing the file.

Lastly, in order to create a new directory we can use the “mkdir” utility (https://man7.org/linux/man-pages/man1/mkdir.1.html) in order to create a new directory or the “rmdir” utility (https://man7.org/linux/man-pages/man1/rmdir.1.html) in order to remove a directory — as shown in the screenshot below (taken using https://copy.sh/v86/?profile=archlinux). A directory is marked with a “d” as the first character in the output of the “ls -l” command (https://man7.org/linux/man-pages/man1/ls.1.html) — also shown in the screenshot below.

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.

--

--