Server Fault is a question and answer site for system and network administrators. 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 run an Ubuntu 10.04 VPS which hosts 2 Thin processes running Ruby On Rails behind Nginx. I control the Thin processes via a /etc/init.d startup script as a regular user. In my Thin config file I specify:

user: www-data
group: www-data

And in my Thin logs, when I start the server, I see

>> Changing process privilege to www-data:www-data

Good sign. Problem is when I run ps -ef my Thin processes are running as the user I login as -- the user I run /etc/init.d/thin start as.

How can I get the Thin processes started as www-data:www-data when I run /etc/init.d/thin start as the user I log into the server as?

share|improve this question
up vote 1 down vote accepted

You can use sudo to run a command as any user:group with these options:

sudo -u www-data -g www-data /etc/init.d/thin start

-u sets the www-data user and -g sets the www-data group

share|improve this answer
This does seem to be the proper way to do it on Ubuntu Linux. It works for other daemons, but not the daemon that I originally posted about (thin). That's due to my RVM environment though.. – Chris Mar 9 '12 at 0:22
Ah, then you will want to use rvmsudo. If you are using rvm, NEVER use sudo. Just replace sudo with rvmsudo like so : rvmsudo -u www-data -g www-data /etc/init.d/thin start – Evan Mar 12 '12 at 20:55

Have you tried to make an :

sudo -c www-data /etc/init.d/thin start

But if your Thin server is listening the port 80, you will need the root privileges.

share|improve this answer

If you're an ordinary user, you will not be able to switch the process ownership to some other user. You will need to run the /etc/init.d/thin script as root to do this.

So, you can do something like sudo /etc/init.d/thin start.

share|improve this answer

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.