25、脚本要以root权限运行。

划词搜索,脚本要以root权限运行。

1、http://bbs.csdn.net/topics/390413278 Ubuntu 10.04 脚本在执行时需要权限怎么办?

chmod 6777 <fileName>  //前面的777前面的6就是设置suid、guid

    无效
    关于chmod和ls -l:
         chmod 777 修改权限 http://www.cnblogs.com/sipher/articles/2429772.html
         linux ls -l 详解[转] http://hi.baidu.com/sfzhaoif/item/3e2653c9426f28d497445220

2、http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=396487&sid=ed6316242e5cc252c26e2f6396738b0d 怎样让shell脚本默认以root权限运行??

suid只对bin有效,当然,echo password |sudo -S也是一个不错的建议。 

      我以为bin是/bin目录,后面才知道应该是二进制文件。
      把密码明文写在脚本里,太不专业了。。

3、http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=105799 在shell脚本中如何使用超权限的命令
       中文没搜到多少,大概就是这些方法
 
4、google:ubuntu script root permission的第一个链接就解决问题:
http://serverfault.com/questions/75620/ubuntu-let-a-user-run-a-script-with-root-permissions
内容见下,老外说得很清楚,很详细。采用了ALL ALL=NOPASSWD: /path/to/script的方法,
这个方法在前面的链接中也有,只是说得太简单,没看懂什么意思。

还是老外靠谱。。。。

划词搜索成功,但是反应太慢。。。。。。


If this was a normal binary, you could setuid by running

# chmod u+s /path/to/binary

Unfortunately, scripts can't be setuid. (Well you can, but it's ignored). The reason for this is that the first line of the script tells the OS what interpreter to run the script under. For example if you had a script with:

#!/bin/bash

You'd actually end up running

/bin/bash /path/to/script

Obviously, you'd need the interpreter to be setuid, which would then mean all scripts would be setuid. This would be bad.

You can do this with sudo by putting the following in your /etc/sudoers file by running visudo.

ALL ALL=NOPASSWD: /path/to/script

And now any user can run

$ sudo /path/to/script

This allows them to run the script without typing in their password.

There is an alternative that doesn't require sudo in the command, which requires creating a small setuided binary that execs your script, but every additional setuid binary adds another potential security problem.



从12年体验12.04 之后放弃,到今年体验14.04,(一转眼两年了,感慨下时光飞逝。。)感觉很糟。。。
Linux的自由开源,我现在没什么感觉。。。
说Linux稳定,我的感觉是比win7死机还频繁,还会出现长按电源键都不反应,要拔电池的情况。。。
说Linux高效,现在基本还在配置系统的状态,一堆细碎问题让我蛋碎神伤。。。
重新熟悉各种常用软件更是让人望而却步。。。。
还是先去学学ps、flash的比较实用。。。。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章