Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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, stephenmyall, 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.

4… ;) – 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
That's why the notice above this question is there, and this question is not deleted. That way, people looking for this question, can find the answer easily. – Camil Staps Jan 6 at 14:55
up vote 187 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?

None of the above. You should 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 (a personal bin folder 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
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
Does placing scripts in /bin cause any problems? I have moved my scripts according to your answer but I am still curious – Rumesh Apr 27 '15 at 12:14
@RumeshSudhaharan you should not do that, because it's managed by the package management. If any other package also wants to use that path, it will overwrite your file. Files in packages can never overlap (at least for official repositories), so you are more safe when installing in the local path. Also, it's just for your own convenience and safety. In a local path you can't mess up the system in such a bad way and you can't accidentally replace a system binary. – gertvdijk Apr 27 '15 at 12:17
@gertvdijk Thanks a lot, now I understand – Rumesh Apr 27 '15 at 12:19
I like the explanation on the error page : Severity:Serious Certainty:Certain – cutrightjm Nov 25 '15 at 6:15

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