rc.local and sudo on CentOS

If you have a sudo command you’re trying to run at startup in your /etc/rc.local on a CentOS system, it might not work. The reason is the following error that’s buried in the /var/log/boot.log file:

It might be hard to find, but you can always add a ‘sleep 30’ before your sudo command in your /etc/rc.local. This way, the message will show up at the end of the boot.log

Anyhow the reason this is happening is for security. To allow sudo on boot, run ‘visudo’ as root and comment out ‘Defaults requiretty’ as seen below:

Now your sudo command should run just fine at boot time.


Here’s an example of why you might want to run sudo at boot.

In the above command, I’m running the script startMinecraft, as the user minesrv. startMinecraft has some screen magic, and I want it tied to the minesrv user.

Leave a Reply
