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!
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityThere 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.
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".