14

Possible Duplicate:
Meaning of directories on Unix and Unix like systems

I'm confused about the different uses for 3 of the standard "root-level" folders: /var /etc /usr

What are the different use cases for these directories?

0

2 Answers 2

17

"/etc" is used for configurations (.conf files etc). here you find all the configs and settings for your system.

"/usr" is used for "user programs". Usually your package manager installs all the binaries, shared files etc. from all programs here (except config files, which go to /etc). You can check /usr/bin for binaries, /usr/share for shared files (media, etc), /usr/share/doc for documentation,...

There is also an "/opt" folder, where there are "other" programs usually put (mostly binary programs, or programs installed from other sources (not the default package manager). Some programs like that (usually compiled) also go to "/usr/local"

"/var" is usually used for log files, 'temporary' files (like mail spool, printer spool, etc), databases, and all other data not tied to a specific user. Logs are usually in "/var/log", databases in "/var/lib" (mysql - "/var/lib/mysql"), etc.

4
  • 1
    What does lib in varlib mean? Why lib?
    – Pacerier
    Aug 22, 2017 at 5:00
  • @Pacerier lib is short for library/libraries.
    – devios1
    Aug 22, 2017 at 17:10
  • @devios1 still doesn't really explain why that folder is so called. mysql is not a library.
    – samlaf
    Feb 5, 2023 at 6:17
  • @samlaf: /var, as the name implies, is for variable (read/write) data that's persistent across reboots (unlike temporary data in /tmp), in contrast with the (mostly) read-only /usr. As for /var/lib, in this particular case the lib subdir means "library" only in a very broad sense, as it actually stands for any specific software or package, as opposed to more general, system-wide subdirs like /var/log which don't belong to any particular package. MySQL example, its read-only files go to /usr/*/mysql, settings at /etc/mysql, and read/write databases at /var/lib/mysql
    – MestreLion
    Jun 11, 2023 at 10:26
3

The /etc/ directory is a common location to put configuration files. (But not the ONLY one by any means.)

The /var directory is the location for "variable" things like logs, running process ID pointer files, spool directories, and other things important for running services.

The /usr/ directory is where user-accessible applications are generally located. Also a case of "by no means all".

4
  • So what would the definition of /usr/etc be? Apr 29, 2012 at 23:21
  • config files for user-supplied application, probably. Personally, I prefer to keep THOSE things over in /opt if they're not part of a package provided with the OS or Distribution.
    – Magellan
    Apr 29, 2012 at 23:27
  • Mind you, none of this is a "rule". It's more tradition and convention and it's transgressed often enough in practice, but is generally-considered a good idea to follow.
    – Magellan
    Apr 29, 2012 at 23:27
  • Right, that's more what I'm aiming towards is best practices. Perhaps a title change? Apr 29, 2012 at 23:36

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