Linux – Should I use `sudo` or `su` in a startup script

linuxsusudosysvinit

I have a personal program, that has a server/client design.

The server daemon part of it, should be run as its own limited user, and the program was not designed to drop its root privileges (if started as root) like some Linux programs do.

So my question, in its startup script in /etc/init.d/, should I use sudo or su to run this daemon as another user? Does it make a difference? Will either of the two even work? Something else?

The operating system is a custom GNU/Linux one, built using "Linux From Scratch" instructions, and does have both programs running correctly.

Best Answer

If you can easily alter the program so that it drops its privileges, then this is the best approach. Switching user ID in the startup scripts is kludgey and rather inflexible, even if it does "work".

Related Question