Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Why are there so many places to put a binary in Linux? There are atleast these five:

  1. /bin/
  2. /sbin/
  3. /usr/bin/
  4. /usr/local/bin/
  5. /usr/local/sbin/

And on my office box, I do not have write permissions to some of these.

What type of binary goes into which of these bins?

share|improve this question
7  
You forgot /usr/sbin/. –  Hello71 Apr 25 '11 at 20:47
2  
And ~/bin/ for personal stuff. –  Calmarius May 12 '13 at 16:01

4 Answers 4

up vote 161 down vote accepted
  1. /bin (and /sbin) were intended for programs that needed to be on a small / partition before the larger /usr, etc. partitions were mounted. These days, it mostly serves as a standard location for key programs like /bin/sh, although the original intent may still be relevant for e.g. installations on small embedded devices.

  2. /sbin, as distinct from /bin, is for system management programs (not normally used by ordinary users) needed before /usr is mounted.

  3. /usr/bin is for distribution-managed normal user programs.

  4. There is a /usr/sbin with the same relationship to /usr/bin as /sbin has to /bin.

  5. /usr/local/bin is for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. You should not install them into /usr/bin because future distribution upgrades may modify or delete them without warning.

  6. /usr/local/sbin, as you can probably guess at this point, is to /usr/local/bin as /usr/sbin to /usr/bin.

In addition, there is also /opt which is for monolithic non-distribution packages, although before they were properly integrated various distributions put Gnome and KDE there. Generally you should reserve it for large, poorly behaved third party packages such as Oracle.

share|improve this answer
18  
pathname.com/fhs for further reference. –  kojiro Mar 5 '11 at 20:27
7  
I think this answer does a great job of clarifying a common set of conventions, but this post from Rob Landley is a really great read if you want insight into the nonsense... lists.busybox.net/pipermail/busybox/2010-December/074114.html –  Subfuzion Dec 13 '12 at 23:45
10  
"large, poorly behaved third party packages such as Oracle", you made my day! –  Totor Mar 21 '13 at 23:37

The Filesystem Hierarchy Standard entry in Wikipedia helped me answer the same question when I had it, plus it has a very explanatory table.

share|improve this answer

I recommend taking a look at the file system hierarchy man page:

man hier

Which is also available online, for instance: http://linux.die.net/man/7/hier

share|improve this answer
    
This doesn't answer the user's question. –  Billy ONeal Mar 5 '11 at 23:54
2  
The man page does contain an entry for each of the bin directories, explaining what goes into them, which was one of the questions. –  davitenio Mar 6 '11 at 6:52
2  
+1 quite handy. –  SalmanPK Jun 8 '13 at 12:56

The sbin directories contains programs which are generally system administration only. Programs for regular users should never go in them.

A few programs are needed during startup, and end up in /bin/ or /sbin/. These must be available before files systems are mounted. Things like mount, and fsck that are required to check and mount files systems must be there.

Most packaged programs end up in /usr/bin/ and /usr/sbin/. These may be on a file system other than the root file system. In some cases they may be on a network mounted drive.

Local programs and scripts belong in /usr/local/bin/ and /usr/local/sbin/. This identifies them as clearly non-standard, and possibly only available on site.

For further explanation try running the command man hier which should provide a description of the recommended file system hierarchy for your distribution. You may also want to read about the File System Hierarchy on Wikipedia

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.