Ubuntu中shell下root用户切换其他用户运行程序 工作中,一些程序,需要随机启动,但是不是以root用户运行,于是需要在rc.local中通过shell,从root用户切换到其他用户运行程序,命令如下: Shell $su -c 'command' - user $sudo -u jetty ./nexus start 123 $su -c 'command' - user $sudo -u jetty ./nexus start 实例 在/etc/rc.local的exit 0之前加入如下内容: Shell #vim /etc/rc.local su - jetty -c "/data/nexus/nexus-2.12.0-01/bin/nexus start" 12 #vim /etc/rc.localsu - jetty -c "/data/nexus/nexus-2.12.0-01/bin/nexus start" 参考链接 shell下root用户切换其他用户运行程序 发布者 默默 码农 查看默默的所有文章