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

原文地址:https://www.cnblogs.com/wangziyi0513/p/10268888.html