the standard paths on Linux

The standard for these issues is the File Hierarchy Standard. It’s a rather big document. Basically (and very roughly), the standard paths on Linux are:

  • /bin & /sbin are for vital programs for the OS, sbin being for administrators only ;
  • /usr/bin & /usr/sbin are for not vital programs, sbin being for administrators only ;
  • /var is for living data for programs. It can be cache data, spool data, temporary data (unless it’s in /tmp, which is wiped at every reboot), etc. ;
  • /usr/local is for locally installed programs. Typically, it hosts programs that follow the standards but were not packaged for the OS, but rather installed manually by the administrator (using for example ./configure && make && make install) as well as administrator scripts ;
  • /opt is for programs that are not packaged and don’t follow the standards. You’d just put all the libraries there together with the program. It’s often a quick & dirty solution, but it can also be used for programs that are made by yourself and for which you wish to have a specific path. You can make your own path (e.g. /opt/yourcompany) within it, and in this case you are encouraged to register it as part of the standard paths ;
  • /etc should not contain programs, but rather configurations.

If your programs are specific to the services provided by the service, /srv can also be a good location for them. For example, I prefer to use /srv/www for websites rather than /var/www to make sure the directory will only contain data I added myself, and nothing that comes from software packages.

There are some differences between distributions. For example, RedHat systems use libexecdirectories when Debian/Ubuntu systems don’t.

The FHS is mostly used by Linux distributions (I actually don’t know any other OS that really complies to it). Other Unix systems don’t follow it. For example, BSD systems tend to use /usr/local for packaged programs, which is not the case for Linux. Solaris has very different standard paths.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s