pm-suspend 必须由 root 运行:
he@x22:~/hep/links$ /usr/sbin/pm-suspend
This utility may only be run by the root user.
我建了一个链接,pms:
he@x22:~/hep/links$ ls -l pms
lrwxrwxrwx 1 he he 20 dec 17 22:13 pms -> /usr/sbin/pm-suspend
和预期的一样:
he@x22:~/hep/links$ ./pms
This utility may only be run by the root user.
但如果我更改目录并将 ~/hep/links 添加到路径中,它对普通用户来说就可以工作:
he@x22:~$ pms
whoami root
为了查看有效用户是谁,我在 /usr/sbin/pm-suspend 的顶部插入了:
#!/bin/sh
echo whoami $(whoami)
.....
root@x22:/home/he/hep/scripts# type -a pms
pms är ett alias för ”sudo pm-suspend”
pms är /home/he/hep/scripts/pms
pms är /home/he/hep/links/pms
有人能解释一下这里发生了什么吗?