Shell脚本中实现切换用户并执行命令操作
时间:2021-06-11 10:58:19
收藏:0
阅读:28
执行多条语句
#!/bin/bash
su - calos <<EOF
pwd;
exit;
EOF
在这种方式中使用到文件路径时,需要使用绝对路径。
执行一条语句
- 切换用户执行一条命令:
su - calos -c command - 切换用户执行一个shell文件:
su - calos /bin/bash test.sh
原文:https://www.cnblogs.com/tudou1179006580/p/14873601.html
评论(0)