指定されたユーザーを使用して、Linuxでコマンドを実行します

1. su(推奨

[root@redhat6 ~]# su - admin -c "id"
uid=500(admin) gid=500(admin) groups=500(admin)
[root@redhat6 ~]#
输出的时 admin 在执行命令 "id" 显示的结果 ,而且执行后并没有切换到"admin" 的console 下 .


# 选删掉swoft所有进程
ps -ef|grep swoft|grep -v grep|awk '{print $2}'|xargs kill -9
# 再用apache启动swoft进程
su - apache -c "/usr/local/bin/php /data/www/vhosts/pixcutapi.wondershare.com/httpdocs/bin/swoft http:start -d"

二、sudo

sudo -H -u www bash -c'nohup / home / web / ke / upfileserver /home/web/ke/up/conf.json& ' 

3、chrootの方法 

chroot --userspec "kibana:kibana" "/" sh -c "/ usr / share / kibana / bin / kibana -c /etc/kibana/kibana.yml" >> /var/log/kibana/kibana.stdout 2 >> /var/log/kibana/kibana.stderr&

おすすめ

転載: blog.csdn.net/JineD/article/details/111517698
おすすめ