I am writing a simple shell script which requires a root privilege. Using the terminal if you type sudo su and you write the password it works definitely.
I want to pass the password to the script file and then pass it to the system to become root ex:
pass= $1
navigateToRoot($pass)
A better approach would be to :
By setting the
setuidbit, the file will execute as root (owner) without having to store or pass the root password.Make sure nobody else can modify the script
SEE COMMENTS:
SETUID does not work on Shell scripts so this answer is INVALID.