Thursday, May 23, 2024
rated 0 times [  523] [ 0]  / answers: 1 / hits: 348885  / 2 Years ago, mon, december 20, 2021, 12:09:42

I have six directories with command files. These are /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin and /usr/local/sbin.

What are the differences between these? If I'm writing my own scripts, where should I add them?


More From » command-line


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 binaries with superuser (root) privileges required.

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

  • /usr/sbin : Same as above, but for binaries 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/.

[#30744] Tuesday, December 21, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 120
Total Questions: 126
Total Answers: 119

Location: Marshall Islands
Member since Wed, Feb 9, 2022
2 Years ago
gavgenerati questions
Wed, Jun 22, 22, 17:24, 2 Years ago
Fri, Jul 30, 21, 04:32, 3 Years ago
Fri, Jan 14, 22, 14:20, 2 Years ago
Tue, Jul 27, 21, 19:05, 3 Years ago