我的系统是 debian 10,只有一个登录用户 boy
具有 sudo
权限。
##!/bin/bash
##root cannot log in
set -e
#expect root
whoami
user='boy'
su $user
#expect 'boy',but not
whoami
su - root
#expect root,but not
whoami
当我 sudo bash ./***.sh
在 bash 脚本之上运行时,预期输出为:
root
boy
root
当sudo bash
脚本只有一个登录用户时如何切换用户?