关于一个链接的问题
opensuse吧
全部回复
仅看楼主
level 1
freechenmu 楼主
suse@linux-337q:~> ls -l /sbin/shutdown
lrwxrwxrwx 1 root root 18 4月 3 12:42 /sbin/shutdown -> /usr/bin/systemctl
suse@linux-337q:~> /sbin/shutdown --help | grep "\-h"
--help Show this help
-H --halt Halt the machine
-h Equivalent to --poweroff, overridden by --halt
suse@linux-337q:~> systemctl --help | grep "\-h"
-h --help Show this help
-H --host=[USER@]HOST
suse@linux-337q:~>
看见了吧shutdown实际只是systemctl的链接。那么为什么shutdown -h和systemctl -h不一样呢?
2015年05月22日 09点05分 1
level 1
一种编程技巧而已。
程式执行前会根据context statement,作不同反应。
以systemctl为例,
如果它发现自己以systemctl这个名字被调用,它就按systemctl来运行。
如果它发现自己以shutdown这个名字被调用,它就按shutdown来运行。
你可以试一下把shutdown这个连接改名为systemctl,你会发现它就是systemctl。
你可以试一下把systemctl这个程式改名为shutdown,你会发现它就是shutdown。
2015年05月22日 14点05分 3
1