#!/bin/bash su - calos <<EOF pwd; exit; EOF
在这种方式中使用到文件路径时,需要使用绝对路径。
su - calos -c command
su - calos /bin/bash test.sh
Shell脚本中实现切换用户并执行命令操作
原文:https://www.cnblogs.com/tudou1179006580/p/14873601.html