The File Hierarchy Standard

by Jon Davis 5. September 2010 00:00

I stumbled upon this while trying to figure out where to copy a Mono app I was deploying to Linux. I’ve always been confused about the *nix file system hierarchy even though they look familiar across the board between Linux, Solaris, Mac, et al. I always thought the “standard” is so ugly and even stupid, and I used that as a reason for dissing Linux but whatever. My negativity dissipates rather quickly when I understand the basics in the first place.

http://serverfault.com/questions/96416/should-i-install-linux-applications-in-var-or-opt

From Raphink:

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.

I strongly encourage you to read the FHS document I linked above if you wish to know more about this.

Nice cheat sheet. I might print this out until I can manage to memorize it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading




 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  August 2020  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

RecentPosts