Are the commands in /etc/rc.local
ran by su
by default?
Do I need to specific sudo
before each command or will they be ran by su
regardless?
Linux – What user runs the commands defined in /etc/rc.local
linuxstartupsusudo
linuxstartupsusudo
Are the commands in /etc/rc.local
ran by su
by default?
Do I need to specific sudo
before each command or will they be ran by su
regardless?
Best Answer
su
is not a user it's program to run subsequent commands/programs under an alternate identity of another user than the one executing the command. It is very similar tosudo
in that regard.Unless another user is specified both commands will default to running the command under the alternate identity of the
root
user, the superuser/administrator.The main difference between
su
andsudo
is that:su
requires you to know the password of that alternate user, wheresudo
will prompt for the password of the user running thesudo
command and requires setup so that the user is allowed to run the requested commands/programs.(When
root
runs eithersu
orsudo
no password is required.)Like any init script, the
/etc/rc.local
script is executed by theroot
user and you do not need to prepend eithersu
orsudo
to the commands/programs that need to run as root.You may still need to use
su
orsudo
in your init scripts if those commands need to be executed not asroot
but another user/service-account...su -
oracle
/do/something/as/oracle/user