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'm told I should run my Rails app as the user www-data, how do I do that? How can I also run say Nginx, and other services as certain users? What is the best practice for this?

share|improve this question
Ubuntu is not a Unix. – Recursion Sep 8 '10 at 7:35
@Recursion: Merely a technicality. All it lacks is the certification. – Ignacio Vazquez-Abrams Sep 8 '10 at 9:33
Thanks for your help @Recursion... – JP Silvashy Sep 9 '10 at 3:25
up vote 2 down vote accepted

Many programs, particularly those intended to be run as daemons, will have a command line flag for which user to run as. These are particularly important for applications which expect to use 'privileged' ports -- under 1024 -- as only root can open listen sockets there. Most such apps will start as root, read the configs, open sockets, then setuid() to a restricted user.

Other programs -- mainly ones that don't need low-numbered ports -- can just be run via an 'su' call in their startup script.

share|improve this answer

The sudo command also does that; checkout its man page.

share|improve this answer

Perhaps, suexec (switch user exec), is what you are looking for.

ubuntu doc

apache doc

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.