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 libc.so.1 => /usr/lib/libc.so.1 libdl.so.1 => /usr/lib/libdl.so.1 动态链接的bin执行的时候使用共享的libraries.他们的文件更小, 而且当libraries更新的时候,他们自动使用更新的libaries 静态链接bin包含了所有的代码,不需要使用共享的libraries. 他们的文件大小比动态链接的bin文件要大. 如果系统 "broken"并且libraries被删除了,损坏了,或者/usr目录没被mounted,/sbin/sh仍然可以执行。 所以推荐大家使用/sbin/sh 作为缺省的root shell
/sbin/sh和usr/bin/sh(/bin/sh)的区别
最新推荐文章于 2023-05-19 15:24:21 发布