Views:
391,407β
Votes: 47β
Tags:
command-line
filesystem
scripts
directory
system
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1045759
Title:
Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin
ID:
/2018/06/11/Differences-between-_bin_-_sbin_-_usr_bin_-_usr_sbin_-_usr_local_bin_-_usr_local_sbin
Created:
June 11, 2018
Edited: June 12, 2020
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
I had a similar question myself a year+ ago: Best directory to place my bash scripts?
System directories for binaries
man hier
(hierarchy) lists all the directories. To get the ones just for binaries use:
$ man hier | grep -E 'bin$|sbin$|^.{7}(/bin)|^.{7}(/sbin)' -A2
/bin This directory contains executable programs which are needed in single user
mode and to bring the system up or repair it.
--
/sbin Like /bin, this directory holds commands needed to boot the system, but
which are usually not executed by normal users.
--
/usr/X11R6/bin
Binaries which belong to the X-Window system; often, there is a symbolic
link from the more traditional /usr/bin/X11 to here.
--
/usr/bin
This is the primary directory for executable programs. Most programs exeβ
cuted by normal users which are not needed for booting or for repairing the
--
/usr/local/bin
Binaries for programs local to the site.
--
/usr/local/sbin
Locally installed programs for system administration.
--
/usr/sbin
This directory contains program binaries for system administration which
are not essential for the boot process, for mounting /usr, or for system
Where to put your own scripts?
For all users to access your scripts you can put them in /usr/local/bin
. Keep in mind you need sudo
access to add / change files here. See: Is there a standard place for placing custom Linux scripts?
For your own user ID scripts put them in /home/YOUR_NAME/bin
. Keep in mind you have to create this directory first and relaunch the terminal to get the path automatically setup by ~/.profile
. See: How to add /home/username/bin to $PATH?
What I know I donβt know
Iβm contemplating taking some of my more complex bash scripts in Ask Ubuntu and setting them up with install scripts on github
. Here are few examples:
- Automatically adjust display brightness based on sunrise and sunset
- Set of countdown timers with alarm
- Application that will lock screen after a set amount of time for Ubuntu
- Code version control between local files and AU answers
I think the scripts should be installed in /usr/bin
which is in the $PATH, but Iβm not sure on the appropriate place yet.