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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -