Linux下/usr/bin與/usr/local/bin/區別總結
很多應用都安裝在/usr/local下面,那么,這些應用為什么選擇這個目錄呢?理解了最根源的原因后,也許對你理解linux組織文件的方式有更直觀的理解。
答案是:Automake工具定義了下面的一組變量:
-
Directory variable Default value
-
-
-
prefix /usr/local
-
-
-
exec_prefix ${prefix}
-
-
-
bindir ${exec_prefix}/bin
-
-
-
libdir ${exec_prefix}/lib
-
-
-
…
-
-
-
includedir ${prefix}/include
-
-
-
datarootdir ${prefix}/share
-
-
-
datadir ${datarootdir}
-
-
-
mandir ${datarootdir}/man
-
-
-
infodir ${datarootdir}/info
-
-
-
docdir ${datarootdir}/doc/${PACKAGE}
-
-
-
…
而GUN下面絕大部分應用的編譯系統都是用automake。
於是乎,你看到的很多很多應用都安裝在了/usr/local/目錄下
二.
首先注意usr 指 Unix System Resource,而不是User然后通常/usr/bin下面的都是系統預裝的可執行程序,會隨着系統升級而改變
/usr/local/bin目錄是給用戶放置自己的可執行程序的地方,推薦放在這里,不會被系統升級而覆蓋同名文件
如果兩個目錄下有相同的可執行程序,誰優先執行受到PATH環境變量的影響,比如我的一台服務器的PATH變量為
echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/dean/bin
這里/usr/local/bin優先於/usr/bin,
/bin
This directory contains executable programs which are needed in single user mode and to bring the sys‐ tem 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/sbin
This directory contains program binaries for system administration which are not essential for the boot process, for mounting /usr, or for system repair.
/usr/local/bin
Binaries for programs local to the site.
/usr/local/sbin
Locally installed programs for system administration.
linux 系統中的 /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin 目錄的區別
Linux修改PATH環境變量
https://www.jianshu.com/p/9d680bdbc170
