Ever been curious about the difference between bin
and sbin
? The ‘s’ in sbin
means ‘system’. Therefore, system binaries reside in sbin
directories.
As you may have noticed, there are a number of different bin
directories in Linux. The best reference I’ve found for an understanding of various Linux folders is man hier
. It provides a brief explanation of the Filesystem Hierarchy Standard (FHS) in Linux. I’ve included a summary of the various bin
and sbin
definitions below:
/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/bin
This is the primary directory for executable programs. Most
programs executed by normal users which are not needed for
booting or for repairing the system and which are not
installed locally should be placed in this directory.
/usr/local
This is where programs which are local to the site typically
go.
/usr/local/bin
Binaries for programs local to the site.
/usr/local/sbin
Locally installed programs for system administration.
If you want to create your own scripts and make them available to all users, you’re pretty safe adding them to /usr/local/bin
. If you want to run scripts using cron
or crontab
, simply use the full path to the command (i.e. /home/user/command
).
What I do is add my scripts to my local bin (~/bin
) and then I create a symbolic link in /usr/local/bin
to the commands I want to make public. As a result, I can manage all my scripts from the same directory but still make some of them publicly available since /usr/local/bin
is added to $PATH
.
Thanks for this – exactly the information I was looking for.
Note that while that’s the current layout/justification, looks like originally it was just because the original unix folks ran out of disk space:
https://news.ycombinator.com/item?id=3519952
http://lists.busybox.net/pipermail/busybox/2010-December/074114.html
[…] http://blog.taylormcgann.com/2014/04/11/difference-bin-sbin/ […]
$PATH is a list of locations that the system checks in order to run applications. So if you run composer from anywhere the system checks the PATH environment variable to see if it knows where the programme is. If its not in the path and you are not running it from the location where its able to be executed then it wont run. echo $PATH to see your path.
[…] 이해하기에 가장 좋은 참고자료는 man hier이에요. 이 커맨드를 사용하면 파일시스템 구조 표준(Filesystem Hierarchy Standard, FHS)에 대한 간략한 설명을 볼 수 있어요. 아래는 여러 bin과 sbin에 대한 […]
THANK YOU….. this helped me understand filesystem…
According to this article, /usr/local and /usr/local/bin are the same thing. This article writer doesn’t appear to have the capacity to explain things very well.
Thanks for pointing out to the man page . It was really helpful
Thanks but what’s a “site” in this context