Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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, theDefector, 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

1 Answer 1

up vote 138 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
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 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 at 12:17
@gertvdijk Thanks a lot, now I understand – Rumesh Apr 27 at 12:19
Amazing that after all these years I've only just found out what the sbin is for. I always assumed sbin was lower priority than bin. Thanks. – Matt Fletcher 15 hours ago

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