Hi, I am trying to login as user1 and run a script which will sudo to a user2 and executes some commands then exit from that user and then execute rest of commands in user1.
Login as user1 and executed this script.
#!/bin/bash
user=$(echo `who am i`| awk '{print $1}')
echo the user is $user
sudo su - user2
mkdir /app/test1
exit
ls -ltr
its sudoing to user2 and its not exiting.
Please advise. Thanks for your help.