0

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!

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.

1

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".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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