Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I'm running an Ubuntu Server 13.04, but I see the same on a 12.04: I have six directories with command files. These are:

  • /bin
  • /sbin
  • /usr/bin
  • /usr/sbin
  • /usr/local/bin
  • /usr/local/sbin

What are the differences between these?
For example: if I'm writing my own scripts, where should I add these?

share|improve this question

marked as duplicate by Eliah Kagan, Basharat Sialvi, Stephen Myall, Eric Carvalho, Radu Rădeanu Jul 22 '13 at 6:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

askubuntu.com/questions/138547/… ;) –  Rinzwind Jun 14 '13 at 9:17
@Rinzwind nice one, thanks! :) –  Camil Staps Jun 14 '13 at 9:18
I don't really consider this a duplicate because this focuses on binary invocations, whereas the other question was more broader in scope and focused on the entire filesystem. –  JohnMerlino Jun 12 '14 at 16:15
@JohnMerlino main point is that this question was answered there. 'Duplicate' is just a term, the real explanation is at the top of the page: "This question already has an answer here:..." –  Camil Staps Jun 14 '14 at 17:34

1 Answer 1

up vote 102 down vote accepted

Please refer to the Filesystem Hierarchy Standard (FHS) for Linux for this.

  • /bin : For binaries usable before the /usr partition is mounted. This is used for trivial binaries used in the very early boot stage or ones that you need to have available in booting single-user mode. Think of binaries like cat, ls, etc.

  • /sbin : Same, but for scripts with superuser (root) privileges required.

  • /usr/bin : Same as first, but for general system-wide binaries.

  • /usr/sbin : Same as above, but for scripts with superuser (root) privileges required.

if I'm writing my own scripts, where should I add these?

Neither of the above. Please use /usr/local/bin or /usr/local/sbin for system-wide available scripts. The local path means it's not managed by the system packages (this is an error for Debian/Ubuntu packages).

For user-scoped scripts, use bin/ in your home directory.

The FHS says for /usr/local:

Tertiary hierarchy for local data, specific to this host. Typically has further subdirectories, e.g., bin/, lib/, share/.

share|improve this answer
I know this was a duplicate question, but thank you for the clear and concise answer. –  Beachhouse Feb 7 '14 at 15:05
so /bin is where all the core files are installed. like ls, cat, pwd, etc? So, /usr/bin is where user installed apps are? what are some examples of what should be in /usr/bin? –  duckx Oct 5 '14 at 16:49

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