Linux下切换用户的命令。比较常用的用法:
1)不切换当前用户,只用指定用户的权限去执行一条命令
[email protected]:/tmp$ su -c "ls /tmp" root Password: ? ThisDIr vmware-file-mod0 config-err-6ha607 unity_support_test.0 vmware-guest-oPvIa8 config-err-NDGsUe vgauthsvclog.txt.0 vmware-guest-QC4Egw config-err-yvEI5R VMTools vmware-jerry dir2 vmware-config0 vmware-root guest-oPvIa8 vmware-config1 VMwareTools-10.0.0-2977863.tar.gz guest-QC4Egw VMwareDnD [email protected]:/tmp$
2)切换用户并指定bash
[email protected]:/tmp$ su -s /bin/bash jerry Password: [email protected]:/tmp$ su -s /bin/sh jerry Password: $
时间: 2025-01-02 15:06:26