I would like to create a script that:
- run some commands
- execute sudo su - [some other username]
- after I exit from [some other username] -> logout
echo "test script" sudo su logout
If I run a script like this:
echo "test" sudo su whomai
I get the wanted result:
[wolfy@ubuntusrv ~ ]# ./test.sh test [root@ubuntusrv wolfy]# date Fri 19 Jun 10:56:52 CEST 2015 [root@ubuntusrv wolfy]# echo bla bla [root@ubuntusrv wolfy]# exit wolfy [wolfy@ubuntusrv ~ ]#
As you can see, the script runs my echo command and then I sudo su to root, where I can do what I need to do and after I quit root session the script execute the last (whoami) command.
My problem is that I can't logout myself at the end of this script.
I need a way to do this without root privileges.
Can someone help me?
- when I run sudo su - username (userA) I need to provide my password (wolfy) to login as the other user (userA). Then I work for the whole session with that user (userA) and when I logout from that user (userA) I would like to automatic logout from my (wofly) user.
- using sudo command is not an option