快速关机 快捷方式如何建?
Tofloor
poster avatar
Dengshuangjang
deepin
2013-12-01 00:10
Author
建了一个快捷方式,双击快捷方式执行的命令是:shutdown -P  1,可建好了后,系统不买帐。不能关系统,进入终端输入这个命令又能关机,当然输密码是必须的。有没有哪们高手能弄一个双击快捷方式就关机的功能呢?
Reply Favorite View the author
All Replies
BingoLove
deepin
2013-12-01 00:12
#1
给你的脚本赋予超级用户权限试试  chmod u+s
Reply View the author
woodelf
deepin
2013-12-01 04:51
#2
两种方法:
1、使用visudo,将shutdown命令设置为不需要root密码,即把
  1. root ALL=(ALL) ALL
Copy the Code
的下一行改为
  1. YOUR_USER ALL=(ALL) NOPASSWD: /sbin/shutdown
Copy the Code
2、或者,直接在你的脚本中通过管道自动输入sudo的密码
  1. echo YOUR_PASSWD|sudo -S shutdown -P 1
Copy the Code
Reply View the author
Dengshuangjang
deepin
2013-12-01 17:41
#3
给你的脚本赋予超级用户权限试试  chmod u+s
好像没得S这项权限了,可分配权限有w r x X,我试过了不行。

sudo chmod ugo+x /sbin/shutdown
Reply View the author
Dengshuangjang
deepin
2013-12-01 17:43
#4
两种方法:
1、使用visudo,将shutdown命令设置为不需要root密码,即把
  1. root ALL=(ALL) ALL
Copy the Code
的下一行改为
  1. YOUR_USER ALL=(ALL) NOPASSWD: /sbin/shutdown
Copy the Code
2、或者,直接在你的脚本中通过管道自动输入sudo的密码
  1. echo YOUR_PASSWD|sudo -S shutdown -P 1
Copy the Code


      看麻,高手不就出来了,网上说得天花烂醉,似乎都不可行,你这招特管用。谢谢,让我再试试……
Reply View the author
Dengshuangjang
deepin
2013-12-01 18:14
#5
[quote]两种方法:
1、使用visudo,将shutdown命令设置为不需要root密码
[/quote]
不行行:
# User privilege specification
root        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL)  NOPASSWD:  /sbin/shutdown
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo        ALL=(ALL:ALL) ALL

后来又改成:
# User privilege specification
root        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo        ALL=(ALL:ALL) ALL


还是不行:

最后想到更绝的:
# User privilege specification
root        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
mmc         ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL:ALL) ALL

还是不得行:

没办法:把%号去掉,问题依旧,怎么办?
Reply View the author
woodelf
deepin
2013-12-01 18:29
#6
[quote][quote]两种方法:
1、使用visudo,将shutdown命令设置为不需要root密码
[/quote]
不行行:
# User privilege specification
root        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL)  NOPASSWD:  /sbin/shutdown
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo        ALL=(ALL:ALL) ALL

后来又改成:
# User privilege specification
root        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo        ALL=(ALL:ALL) ALL


还是不行:

最后想到更绝的:
# User privilege specification
root        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
mmc         ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo        ALL=(ALL:ALL) ALL
mmc         ALL=(ALL:ALL) ALL

还是不得行:

没办法:把%号去掉,问题依旧,怎么办?[/quote]
ubuntu的sudoer文件语法不太一样啊,改成这样:
  1. mmc ALL=(ALL:ALL) NOPASSWD: /sbin/shutdown
Copy the Code
第二种方法也可以试试。
Reply View the author