I want to add a new user to my CentOS 6 server (let's call him Barry). I've made the user account Barry and added him to a group I created called webusers like this:

groupadd webusers
useradd -G webusers Barry
passwd Barry

Now that I have a user account all set up with a password and added to a group, I want to give the group permission to write to the nginx config file, restart nginx, and do whatever they need to do in /var/www/ like create files/directories etc.

The nginx config file is located here:


To restart nginx, I want the webusers group to be able to run the following command:

/etc/init.d/nginx restart

And I want to give them permissions to read and write to this directory:


chmod looks horribly confusing to me, I've never had to use it before and I'm kinda new to system administration.


For the nginx conf file, simply make it group writable:

chgrp webusers /webservers/nginx/conf/nginx.conf
chmod 664 /webservers/nginx/conf/nginx.conf

To allow the webusers group to restart the service, it'll be easiest to do this with sudo. If it's not installed, install with (as root):

yum install sudo

Then edit /etc/sudoers with:


Add some entries like:

Cmnd_Alias NGINX=/sbin/service nginx restart
%webusers ALL = NGINX

This will allow members of the webusers group to run the command sudo service nginx restart.

For /var/www you'll need to add group write and add the setgid bit to the directory to ensure new files have group webusers:

chgrp -R webusers /var/www
chmod 2775 /var/www

Here is a great primer on unix permissions (and using chmod/chown/etc). It sounds like you'll want /var/www to be owned by the webusers group and with the g+s permission. You'll probably want to read up on umask and considering having these users use umask 002 for this shared directory.

/etc/init.d/nginx is going to require root permissions since it will want to bind to port 80, for that you'd use sudo. There should be tons of resources out there for setting up sudo, including the sudoers manpage.

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.