歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> /sbin/sh和usr/bin/sh(/bin/sh)的區別

/sbin/sh和usr/bin/sh(/bin/sh)的區別

日期:2017/2/28 11:19:42   编辑:關於Unix


/sbin/sh and /usr/bin/sh shells 都是 Bourne shells.
/sbin/sh is statically linked
/usr/bin/sh is dynamically linked.
/bin/sh /bin目錄是到/usr/bin的鏈接
先看看屬性:
# ls -l /sbin/sh
-r-xr-xr-x 2 bin root 251712 Jul 16 1997 /sbin/sh
# ls -l /usr/bin/sh
-r-xr-xr-x 3 bin root 88620 Jul 16 1997 /usr/bin/sh
# file /sbin/sh
/sbin/sh: ELF 32-bit MSB executable SPARC Version 1, statically linked, stripped
# file /usr/bin/sh
/usr/bin/sh: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped
# ldd /sbin/sh
ldd: /sbin/sh: file is not a dynamic executable or shared object
# ldd /usr/bin/sh
動態鏈接的bin執行的時候使用共享的libraries.他們的文件更小,
而且當libraries更新的時候,他們自動使用更新的libaries
靜態鏈接bin包含了所有的代碼,不需要使用共享的libraries. 他們的文件大小比動態鏈接的bin文件要大.
如果系統 "broken"並且libraries被刪除了,損壞了,或者/usr目錄沒被mounted,/sbin/sh仍然可以執行。
所以推薦大家使用/sbin/sh 作為缺省的root shell
Copyright © Linux教程網 All Rights Reserved