shell - Run multiple commands in linux without logging as root user? -
i want write script, want run non-root user, script contains multiple commands.
for ex: sudo -i hostname df -h
i tried same 3 commands in script it's logging root user , not executing hostname
, df -h
command.
if want run command root privileges use
sudo command,
command
sudo -i
will log root's shell. if want run multiple commands should use
command1 && command2
it runs command2 after command1 sucesuflly finished.
if need root's privileges in script maybe should use sudo when executing script, , in script check if user has necessary privileges (http://www.cyberciti.biz/tips/shell-root-user-check-script.html).
Comments
Post a Comment