Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a process of mine running as root (say a webserver) and I want it to be run as non-root.

Is there a way to change the ownership of a process from root to an unprivileged user?

I am working on a Debian machine.

Thanks!

share|improve this question

2 Answers 2

There isn't any sensible universal way to change the ownership of a running process from outside that process. Processes can change their own ownership from root to non-root using setuid(2) system call. If the webserver in question is Apache, you can configure what users it runs as by editing /etc/apache2/envvars and restarting it.

share|improve this answer

as webservers needs to listen at port 80 or 443 it needs to start as root to bind to those ports. If the program itself doesn't support running as non root user, you can't force it to.

The alternative is to make it listen on port greater than 1024 and redirect traffic using iptables but it's highly "hackish".

share|improve this answer

Your Answer

 
discard

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.