Ubuntu – Automate switch user in script

scriptingsuUbuntu

I have to write a script on ubuntu and some commands require root privileges. The script is full of normal linux commands. Is it possible to write a switch user(su) script that automates the password prompt without needing user intervention?. Need help…

I forgot to tell you that I'm asked to disable sudo access to all users and I did that. Alternate option?

Thank you!

Best Answer

you should use sudo. In the file /etc/sudoers you can configure the commands which should be run with root privileges and whether a password is needed or not.