What are /etc, /var, /bin, /opt in Linux
Being a frontend developer in my first year of work, these Linux folders always used to confuse me. What are they, and why are they named like that? I recall setting up Nginx on my MacBook for some development tasks. I would always ask the DevOps guy in my office where to find the Nginx config file. He would simply say, "Just go to /opt/homebrew/etc/nginx
, and you'll find it." I used to wonder how they remembered all that information.
Recently, I realized I needed to learn about this and write a blog post. So, let's dive in and explore "some" of the Linux File System.
So, /etc
, /var,/bin
, and /opt
folders are part of the larger File System Hierarchy in Linux. There are specific requirements and guidelines for where files and directories should be placed in Linux according to FHS (Formerly, FSSTND). FHS stands for Filesystem Hierarchy Standard, while FSSTND stands for Filesystem Standard. In this blog, I will focus on explaining these four folders mentioned above.
Let's start with /bin
. "bin" stands for "binary," and this is where the essential executable binary files (i.e., compiled machine code) are stored for various system commands and utilities. So, common commands like cp, mv, rm, cat, grep, etc., are stored here.
Coming to /var
, "var" stands for "variable," and it contains data files that are expected to change during the normal operation of the system. For instance, in /var/log, you can find all the logs of your apps.
/etc
is where all the configuration files for your applications are stored. "etc" actually stands for "etcetera" but can also be seen as "editable-text-configurations." The origin of this name dates back to a time when people had folders like /bin for specific purposes but lacked folders for files such as configuration files, data files, or socket files. Although now it is mainly for configuration files, the name has remained unchanged.
/opt
is used to store all third-party software packages in your system that are not part of the core operating system. This is where my story of finding the nginx config begins. Knowing that I installed nginx using a homebrew formula, and homebrew is third-party software on my computer, I can navigate to /opt/homebrew
first. I also know that configuration files are in the /etc directory. So, I can search for either /opt/homebrew/etc
or /opt/homebrew/nginx
. /opt/homebrew/etc/
is the correct path, and then I navigate to /opt/homebrew/etc/nginx
to locate where the nginx.conf file is stored.
Now I know where to look for the nginx.conf
file, so I don't have to feel frustrated or bother the devops guy every time I need to edit it! One fun fact I got to know while researching about this topic is that the full form of Linux is "Lovable Intellect Not Using XP". Thanks for reading and Happy coding!
Subscribe to my newsletter
Read articles from sathwikreddy GV directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
sathwikreddy GV
sathwikreddy GV
Seeking to make an impact in the field of software engineering.