300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux下普通用户执行root权限脚本

linux下普通用户执行root权限脚本

时间:2022-06-24 17:52:25

相关推荐

linux下普通用户执行root权限脚本

1.安装expect

yum install -y expect

2.示例

a.admin切换root用户脚本

#!/usr/bin/expectset passwd "123456"set timeout 30spawn sudo su -expect "*password*"send "$passwd\r"interact

b.执行root权限脚本,比如createhellomv.sh为root权限脚本

#!/usr/bin/expectset passwd "12345"set timeout 30spawn sudo sh /opt/service/hellojenkins/createhellomv.shexpect "*password*"send "$passwd\r"interact

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。