I have an authoritative DNS daemon in my test DNS setup which is responsible to provide host IP at best choice.

This daemon/process can run by setting some capabilities using setcap and then a development user can start or stop this without becoming the root user or using sudo.

But while booting up the box, this daemon/process again appears as running as root in ps output.

Can I start/stop this process with minimal capability/privileges from a non-root user? Then, at the bootup, I also don't want to see this running as the root user.

Is there any mechanism in init scripts to run the given process with non zero uid?


You could use su in your startup scripts:

su -s /bin/sh -c '/usr/bin/somedaemon' someuser

Another solution would be to start the daemon using cron.


You should just call:

sudo -u username your_daemon_name

in the init script, as root runs the init script it will not ask for a password but run the scripts as username.


If you are using systemd (as of today, only Slackware, Ubuntu and Debian among Linux distributions are using anything else) you can set the user/group in its .service file (see systemd.service(5), systemd.exec(5), and browse through the copious documentation here).

  • Ubuntu and Debian are both using systemd now. I think Slackware is the only major distro left to not use systemd (at least judging from the list of most popular distros at distrowatch). – Alexander Jul 28 '17 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.