0

My system is debian 10,has only one login user boy with sudo privilege.

##!/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

When I sudo bash ./***.sh to run above bash script,expect output is:

root
boy
root

How to switch user when sudo bash script with only one login user?

kittygirl
  • 2,255
  • 5
  • 24
  • 52

0 Answers0