方法汇总:

1、su

2、sudo

3、runuser

比较常用的方式:su

示例:su - root -s /bin/sh -c "/usr/local/nginx/sbin/nginx",解释:以root身份,用/bin/sh运行命令。