bin目录区别

https://php-osx.liip.ch/



Why are there so many places to put a binary in Linux? There are at least these five:



/bin/
/sbin/
/usr/bin/
/usr/local/bin/
/usr/local/sbin/

/bin (and /sbin) were intended for programs that needed to be on a small / partition before the larger /usr, etc. partitions were mounted. These days, it mostly serves as a standard location for key programs like /bin/sh, although the original intent may still be relevant for e.g. installations on small embedded devices.



/sbin, as distinct from /bin, is for system management programs (not normally used by ordinary users) needed before /usr is mounted.



/usr/bin is for distribution-managed normal user programs.



There is a /usr/sbin with the same relationship to /usr/bin as /sbin has to /bin.



/usr/local/bin is for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. You should not install them into /usr/bin because future distribution upgrades may modify or delete them without warning.



/usr/local/sbin, as you can probably guess at this point, is to /usr/local/bin as /usr/sbin to /usr/bin.



https://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux



/usr/bin下面的都是系统预装的可执行程序,会随着系统升级而改变。
/usr/local/bin目录是给用户放置自己的可执行程序的地方,推荐放在这里,不会被系统升级而覆盖同名文件。



如果两个目录下有相同的可执行程序,谁优先执行受到PATH环境变量的影响,比如我的一台服务器的PATH变量为。
echo $PATH



/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin



/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, 一般都是如此。



新版本mac 修改/usr/bin下的文件,提示operation not permitted
但是我们在对 usr/bin 目录下的文件进行操作的时候往往会出现这样的错误



operation not permitted
这是因为一些mac用户在升级系统之后,电脑启用了SIP(System Integrity Protection),增加了rootless机制,导致即使在root权限下依然无法修改文件,在必要时候为了能够修改下面的文件,我们只能关闭该保护机制



1)重启,过程中按住 command+R,进入保护模式



2)打开terminal终端,输入



1
csrutil disable
3)再次重启,即可对 usr/bin 目录下文件进行修改



PS:如果要恢复保护机制,重新进入保护模式,输入



1
csrutil enable


Category linux