Do binaries from this get source
immediately?
Do I need to add it to bash profile to be sourced?
If I understand correctly, there are other places for binaries like:
/usr/bin
/bin
/usr/local/bin
Why so many?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityDo binaries from this get source
immediately?
Do I need to add it to bash profile to be sourced?
If I understand correctly, there are other places for binaries like:
/usr/bin
/bin
/usr/local/bin
Why so many?
The bin
folders are used for executable programs.
Before Ubuntu 19.10 the folder of /bin
itself was used for minimal functionality for the purposes of booting and repairing a system. The /usr/bin
folder was used for most of the executable programs. Now /bin
is symlinked to /usr/bin
so they are now one and the same.
$ lsb_release -r
Release: 20.04
$ ls -al /
total 104
drwxr-xr-x 20 root root 4096 Apr 16 08:28 .
drwxr-xr-x 20 root root 4096 Apr 16 08:28 ..
lrwxrwxrwx 1 root root 7 Oct 2 2021 bin -> usr/bin
$ lsb_release -r
Release: 18.04
$ ls -al /
total 1459924
drwxr-xr-x 24 root root 4096 Feb 24 07:36 .
drwxr-xr-x 24 root root 4096 Feb 24 07:36 ..
drwxr-xr-x 2 root root 4096 Feb 24 07:11 bin
The /usr/local/bin
is used for executable programs that are not managed by a distribution package.
The answer for your $HOME/bin
folder is contained in the .profile
in your home folder (/home/<user>/
). It (.profile
) is sourced automatically when you log in.
Contained in the .profile
file in your home folder are the following sections (It is all about preference):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
If either of those bin
folders exist they are automatically added to the $PATH
when the user logs into their account. It is used for the user's own private executable programs and scripts. They are primarily used for the user or owner of those folders, keeping them private from other users.
Linux systems are multiuser, even if there is only 1 person using the system. That's worth remembering.
The major Linux distros follow (mostly) the Linux File System Hierarchy Standards document. A summary of what each directory is for can be found in the wikipedia article by that name. https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard It closely follows the UNIX File System Hierarchy Standards that has been around 30+ yrs. I don't know if UNIX standards are truly standard, but they all seem to be very similar.
The only place that I see where those standards are violated on Ubuntu (and some other distros) is related to /media/ and where ever snap packages go. But that's a different question.
/home/username/bin
(also written as$HOME/bin
) instead of/home/bin
?