Linux下/usr/bin與/usr/local/bin/區別總結


Linux下/usr/bin與/usr/local/bin/區別總結

 版權聲明:本文為博主原創文章! github地址:https://github.com/lina-not-linus 博客地址: https://blog.csdn.net/Lina_ACM/article/details/78224656
一.

很多應用都安裝在/usr/local下面,那么,這些應用為什么選擇這個目錄呢?理解了最根源的原因后,也許對你理解linux組織文件的方式有更直觀的理解。
答案是:Automake工具定義了下面的一組變量:

  1.  
    Directory variable Default value
  2.  
     
  3.  
     
  4.  
    prefix /usr/local
  5.  
     
  6.  
     
  7.  
    exec_prefix ${prefix}
  8.  
     
  9.  
     
  10.  
    bindir ${exec_prefix}/bin
  11.  
     
  12.  
     
  13.  
    libdir ${exec_prefix}/lib
  14.  
     
  15.  
     
  16.  
  17.  
     
  18.  
     
  19.  
    includedir ${prefix}/include
  20.  
     
  21.  
     
  22.  
    datarootdir ${prefix}/share
  23.  
     
  24.  
     
  25.  
    datadir ${datarootdir}
  26.  
     
  27.  
     
  28.  
    mandir ${datarootdir}/man
  29.  
     
  30.  
     
  31.  
    infodir ${datarootdir}/info
  32.  
     
  33.  
     
  34.  
    docdir ${datarootdir}/doc/${PACKAGE}
  35.  
     
  36.  
     
  37.  

而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,
 
https://blog.csdn.net/lina_acm/article/details/78224656
 
 
 

/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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM