Register
It is currently Sun Apr 22, 2018 9:41 pm

run a non-login non-interactive bash shell as another user


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue Mar 07, 2017 12:17 am   

Joined: Mon Mar 06, 2017 11:57 pm
Posts: 1
Hello

I have to use a bash shell as another user in order to compile source code. I'm use Debian 8.7 and has set bash instead dash as default shell. Further I has enabled sudo and disabled su. In order to run a bash shell as another user, I use the sudo command:
sudo -H -u anotheruser /bin/bash -c "command"

Now I have recognized, that a the user id isn't that from anotheruser but the one from the user, that starts the command sudo -H -u ...
sudo -H -u anotheruser /bin/bash -c "echo `id -u`"

Also other environment variables are set from the user that starts the command sudo -H -u anotheruser instead from anotheruser.
So, any hints are welcome, that helps me to understand what I'm doing wrong.

Kind regards.


Top
 Profile  
 PostPosted: Tue Mar 07, 2017 7:01 pm   

Joined: Mon Oct 20, 2014 9:53 am
Posts: 574
That's how sudo works by definition.

Use su SomeOtherUser -c bash [SomeScript]


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP