Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to start the Tor daemon as another user. When it installs, Tor automatically creates a new user "debian-tor", however, it does not run as this user, but rather as root.

In Debain 5 I removed Tor from start up with Update-rc.d, and added a new start up script that basically does su debian-tor -c '/etc/init/tor $1'. This worked great, but in Dabian 6 (using insserv instead of update-rc.d) it asked for debiant-tor's password (in spite of running as root).

I'm at a loss here, my iptables will only work if Tor runs as a different user, and it's much safer not to run it as root. What can I do?

share|improve this question

migrated from stackoverflow.com May 23 '11 at 12:36

This question came from our site for professional and enthusiast programmers.

I can see in my rc.d that the debian daemon starter can accept users `grep -nire start-stop-daemon /etc/init.d/ /etc/init.d/xpilot-ng-server:35: start-stop-daemon --start --quiet --chuid $USER --background ` – Lmwangi May 23 '11 at 13:25

Services are usually meant to run as root. However, you have 2 options:

  1. You have some sort of script that launches the service as that user. There are a few ways to accomplish this. You could do the following:

    sudo -u debian-tor /etc/init.d/service

    and then add debian-tor to the sudoer's file for this command

  2. You can use the stop-start-daemon with the --chuid option.

share|improve this answer
This is a partial solution. It seems that init.d/tor runs as root and then drops to debian-tor. It does open ports with the uid of root, which made the iptables rules not function properly. I tried checking with ps and lsof, all the relevant ports seemed to belong to debian-tor, so I really don't understand what could be causing this. Is there any other thing I can check or change? – user May 25 '11 at 13:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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