Why are 'folders' called 'directories' in Linux? | Linux China
Takeaway: If you're wondering why folders are called directories in Linux, here are some explanations.
Number of characters: 1660, reading time about: 2 minutes
https://linux.cn/article-14137-1.html
His : Abhishek Prakash
Translator: Xingyu.Wang
If you're starting out with a Windows computer, chances are you'll use the term "folder".
But when you switch to Linux, you'll find that folders are often called "directories".
This may confuse some new Linux users. Should you call it a folder or a directory? Are they different?
Here's the thing. You can call it a folder if you like, or a directory if you like. It makes no difference.
However, if you are wondering why folders are called directories in Linux, here are some explanations.
Why are folders called directories in Linux?
Before I explain, let's review how folders and directories are used in the real world.
In reality, folders (envelopes) can be used to hold several files (or other items). Directories, on the other hand, can be used to maintain an index of items so you can find which item is located where.
Now, let's go back to the directory. The term existed even before Linux existed. It comes from the UNIX era. Linux has inherited many things from UNIX, and this is just one of them.
Now let me tell you something that may surprise you. Directories don't really put files in them. A directory is a "special file" that knows where the file is in storage (via an inode 🔗 linuxhandbook.com).
That explains why it's called a directory. Directories are used to hold an index of items, not the items themselves. A directory in Linux and UNIX does not hold the files within it. They just record information about the location of the file.
If you want to learn more about it, my article on hard links 🔗 linuxhandbook.com should help you.
So why is it called a folder? In my opinion, it's the point of view. When you're in a graphical environment, you visualize things. Here, files can be visualized like pages, which are stored in an envelope (folder).
When operating systems started using graphical elements, I think some terminology changed accordingly, directory -> folder being one of them.
Should you call it a folder or a directory?
It's entirely up to you. You can use these two terms however you like.
However, if you are learning the Linux command line or use it a lot, using the term directory might help a little.
There are some Linux commands like mkdir, rmdir, etc. The term "dir" gives a hint that these commands are related to directories.
Likewise, many Linux commands and bash scripts use the options -d for directories and -f for files.
Even the file attributes in the terminal distinguish between files and folders (directories) by prefixing the directory with the letter "d".
Take this example, I have a file named some and a folder/directory named something. Note how various Linux commands use "dir" or "d" to distinguish files and directories.
Example showing the difference between file and directory operations
All of this makes me think that the term "directory" would be beneficial when using Linux commands. Your subconscious will more easily associate "dir" and "d" with directories.
Again, it's entirely up to you whether you want to call it a folder or a directory. People will understand what you mean.
I've just done some analysis of the historical origins of the word directory, which should give you some hints as to why people say "In Linux/UNIX, everything is a file".
Now that I'm done with my gibberish, I invite you to comment on it. Please let me know if you find any technical inaccuracies.
via: https://itsfoss.com/folder-directory-linux/
Author: Abhishek Prakash Topic: lujun9972 Translator: wxy Proofreading: wxy
This article was originally compiled by LCTT, and was launched with honor by Linux China
Welcome to reprint in accordance with the CC-BY-NC-SA agreement,
If you want to reprint, please leave a message under the article " Reprint: Official Account Name ",
We will add a whitelist for you to authorize " modification when reprinting articles ".
終端大師 Terminal Master