Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was asked a question today that I can't seem to answer at the moment. My colleague wants to know how he can run a script as UserB from UserA. For example, if he was doing this process manually he would:
1. su - UserB
2. Enter password
3. Run commands as UserB
4. Exit back to UserA shell
However, su as far as I know doesn't accept passwords other than from a local tty. sudo also won't accept a piped in password and rexecd may not be running or available.
So my question to you guys is, how can I help him automate this process?
set up sudo correctly using "NOPASSWD" for whatever command it is and then 'sudo -u userb command'
Set the script owned by userb and chmod it 4750 (adding user A to whatever group owns the script)
If it's an automated thing, put the script in userb's crontab
etc
etc
etc
Hi David, thanks for the response. I did check out sudo but I was having problems with entering a password. I appreciate the fast response.
sigsegv has enlightened me... I didn't know there was a NOPASSWD option. I'll pass your suggestions to my colleague and he'll be very happy.
Thanks guys.
J.
Quote:
Originally posted by sigsegv set up sudo correctly using "NOPASSWD" for whatever command it is and then 'sudo -u userb command'
Set the script owned by userb and chmod it 4750 (adding user A to whatever group owns the script)
If it's an automated thing, put the script in userb's crontab
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.