find out nginx user

How to Check What User NGINX is Running As

Sometimes you may need to find out what user NGINX is running as. Here is how to check what user NGINX is running as using ps command.


How to Check What User NGINX is Running As

ps command lists all processes in your system. You can easily determine the user running NGINX server with the following command.

$ sudo ps aux| grep nginx

In the above command, ps command will list all active processes and pass its output to grep where we search for lines containing “nginx”.

You will see an output similar to the following.

www-data  1488  0.0  0.1 162184  7634 ?        Ss   Apr29   0:02 /usr/bin/nginx
www-data  1497  0.0  0.1 162184  7268 ?        S    Apr29   0:00 /usr/bin/nginx
www-data  1498  0.0  0.1 162184  7926 ?        S    Apr29   0:00 /usr/bin/nginx
www-data  1422  0.0  0.1 162184  7784 ?        S    Apr29   0:00 /usr/bin/nginx

You an even use top or htop command to find NGINX user.

You can also open NGINX configuration file to view the user. Let us say your NGINX configuration file is located at /home/ubuntu/nginx.conf. Use the following command to open it in a text editor.

$ sudo vi /home/ubuntu/nginx.conf

Look for the user directive. It will give you the username running NGINX. Here is an example.

user www-data

Also read : How to Configure TLS/SSL passthrough in NGINX



Change NGINX User

If you want to change NGINX user just open NGINX configuration file as shown above

$ sudo vi /home/ubuntu/nginx.conf

and update user directive with new user (e.g nginx_user). Change

user www-data

to

user nginx_user

Restart NGINX server to apply changes.

$ sudo /usr/bin/nginx -s reload

In this article, we have learnt how to find out which user is running NGINX server, and also how to change it.

Also read : How to Fix NGINX : Too Many Open Files Error


Leave a Reply

Your email address will not be published. Required fields are marked *