147

I've been using Linux for a couple of years now but I still haven't figured out what the origin or meaning of some the directory names are on Unix and Unix like systems. E.g. what does etc stand for or var? Where does the opt name come from?

And while we're on the topic anyway. Can someone give a clear explanation of what directory is best used for what. I sometimes get confused where certain software is installed or what the most appropriate directory is to install software into.

2
  • Funny thing unix being a parody of multics and being the one to survive... I guess multics was just way ahead of it's time.
    – SparK
    Aug 17, 2018 at 13:33
  • help.ubuntu.com/community/LinuxFilesystemTreeOverview this link has a good authoritative description of the various items, specific to ubuntu ( what I was looking for)
    – Gautam
    Mar 8, 2023 at 7:35

7 Answers 7

185

For more data on the layout of Linux file-systems, look at the Filesystem Hierarchy Standard (now at version 3.0). It does explain some of where the names came from:

  • /bin - Binaries.
  • /boot - Files required for booting.
  • /dev - Device files.
  • /etc - Et cetera. The name is inherited from the earliest Unixes, which is when it became the spot to put config-files.
  • /home - Where home directories are kept.
  • /lib - Where code libraries are kept.
  • /media - A more modern directory, but where removable media gets mounted.
  • /mnt - Where temporary file-systems are mounted.
  • /opt - Where optional add-on software is installed. This is discrete from /usr/local/ for reasons I'll get to later.
  • /run - Where runtime variable data is kept.
  • /sbin - Where super-binaries are stored. These usually only work with root.
  • /srv - Stands for "serve". This directory is intended for static files that are served out. /srv/http would be for static websites, /srv/ftp for an FTP server.
  • /tmp - Where temporary files may be stored.
  • /usr - Another directory inherited from the Unixes of old, it stands for "UNIX System Resources". It does not stand for "user" (see the Debian Wiki). This directory should be sharable between hosts, and can be NFS mounted to multiple hosts safely. It can be mounted read-only safely.
  • /var - Another directory inherited from the Unixes of old, it stands for "variable". This is where system data that varies may be stored. Such things as spool and cache directories may be located here. If a program needs to write to the local file-system and isn't serving that data to someone directly, it'll go here.

/opt vs /usr/local

The rule of thumb I've seen is best described as:

Use /usr/local for things that would normally go into /usr, or are overriding things that are already in /usr. Use /opt for things that install all in one directory, or are otherwise special.

/usr/lib vs /lib

Several Linux distributions have taken the step to make /lib a symlink to /usr/lib (Fedora started in 2012, Ubuntu as of 19.04, OpenSUSE began in 2020). This step was controversial as it violates one of the original intentions of having these two directories split: you should be able to boot a system using only what is in /lib. This guidance dates from eras when it was quite common to have many disks and partitions on a system, allowing administrators to separate what goes into /lib versus /usr/lib and similar. Practice in the last couple of decades has drifted away from managing these directories separately, so the distros decided to go where the users are and effectively unify them. This unification makes it easier for package maintainers, since there are fewer places to manage files.

6
  • 2
    The document answers the first half of my question very well. However, where the names are derived from is still a mystery. The reason I'd like to know is because I think it will give me more context.
    – Luke
    Jun 12, 2009 at 9:31
  • The naming is nearly all self explanatory. Especially if you read through the descriptions in that link.
    – Dan Carley
    Jun 12, 2009 at 9:35
  • 5
    No it isn't. It explains what 'etc' is used for but is doesn't explain where the name comes from or what it stands for.
    – Luke
    Jun 12, 2009 at 21:18
  • @sysadmin1138, so /run is basically referencing the RAM?
    – Pacerier
    Dec 19, 2014 at 5:59
  • 2
    I guess 'var' is "variable" in the sense the contents are constantly changing while programs are running (as opposed to config and binary files which are only created or modified during steps like installation or initial setup). Analogous to compile-time vs runtime in programming. Sep 6, 2017 at 21:20
30

Sorry to resurrect an old thread, but I feel this detail is an important clarification for all future seekers of this info:

  • /opt stands for optional (as in optional add-on packages).
  • /bin stands for binary (contains executables used by the OS).
  • /lib stands for library (contains shared libraries used by filesystem and for booting, probably used by the executables in bin)
  • /proc stands for processes.
  • /root means root user.
  • /home holds the home sub-directories for any non-root users.
  • /dev stands for device (holds special and device files).
  • /tmp stands for temporary.
  • /srv stands for serve.
  • /mnt stands for mount point (mount a temporary filesystem here).
  • /include contains #include files, i.e. header files (e.g., stdio.h).
  • /var stands for variable
  • /etc stands for etcetera

  • /usr stands for Unix System Resources(Source)

2
  • Nice answer: succinct, directed at the level of the question, and no need to look up other links. +1
    – SMBiggs
    Jul 28, 2014 at 13:37
  • I haven't seen srv before. I prefer convention over configuration, so long as it makes sense and is enforced. Obviously, Apache doesn't always serve files from the /srv directory.
    – user148298
    Sep 11, 2018 at 13:34
24

Try this:

$ man hier
3
  • 2
    Nice one. However, just like the document referred to in other answers, this man page only talks about what the directories are used for. I'm also interested in why certain names where chosen, like /etc e.g.
    – Luke
    Jun 23, 2009 at 22:33
  • 2
    The answer to your question about /etc is here: en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
    – Anonymous
    Jun 24, 2009 at 12:37
  • This is the answer. Thanks
    – Fatih
    Jan 9, 2020 at 12:30
22

Historically, /etc stands for "etcetera" and /var is short for "variable." I suppose the former is because a large collection of unrelated system configuration files go into /etc. The latter is because the files in /var are expected to change. You can often mount /usr and / as read-only (except when performing updates), but you can never mount /var read-only. It hold system logfiles, lock files, spool files, and other things that change dynamically.

Other people gave you pointers to help you figure out what best goes where.

7

The best place to look for this is the Filesystem Hierarchy Standard (FHS). The latest version is 2.3 available at: http://www.pathname.com/fhs/pub/fhs-2.3.html.

2

/usr actually means Unix System Resources

source:: https://wiki.debian.org/FilesystemHierarchyStandard

1

If you observe several flavours of unix operating system than you will find some what difference in directory names, but most of the common are explain below...

/bin stands for binary (contains binary files and also contains commands mostly used by users. It is also the default path for command execution ).

/sbin ( this contains the special commands which are generally fired by super user)

/lib stands for library (contains shared libraries used by filesystem and for booting, probably used by the executables in bin) /proc stands for processes(if you wanna verify just check this director it will contain several directories named in random numbers, that are nothing but process number you can cross check by ps - ef)

/root means root user.( default directory for root user) /home ( all the non-root users have there home directory under this directory) /dev stands for device (holds special and device files, if you look in this directory via ls - l command major and minor numbers are also shown in this directory also the device type shown at starting of each line in ls - l result. B means block special device, c means character special device ). /tmp stands for temporary.( temporary resources required for some process kept here temporarily ) /mnt stands for mount point (mount a temporary filesystem here). /var stands for variable( it holds variable data, the directory it contains are changing in size every time) /opt stands for optional (generally third party Software are installed in this directory). /usr stands for Unix System Resources.( all the system required resources are placed here) /etc stands for etcetera ( it is also important one, most of the configuration files, user management files, security files and other things are kept under this)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .