无意中找到的一个帖子,讲的是Linux系统中[几个 PATH 的区别](http://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux).
1. `/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.
2. `/sbin`, as distinct from `/bin`, is for system management programs (not normally used by ordinary users) needed before `/usr` is mounted.
3. `/usr/bin` is for distribution-managed normal user programs.
4. There is a `/usr/sbin` with the same relationship to `/usr/bin` as `/sbin` has to `/bin`.
5. `/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.
6. `/usr/local/sbin`, as you can probably guess at this point, is to `/usr/local/bin` as `/usr/sbin` to `/usr/bin`.
In addition, there is also `/opt` which is for monolithic non-distribution packages, although before they were properly integrated various distributions put Gnome and KDE there. Generally you should reserve it for large, poorly behaved third party packages such as Oracle.
当前我的 CentOS 系统下 PATH 的确是将这几个路径依次排列的: `:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:` 显然用户自行编译的包会优先被使用,而且用户不应当用自己编译的东西替换掉 `/usr/bin` 或是 `/usr/sbin` 里面的内容.
评论