Add a Linux User With Document Root Permissions

Table of Contents

In this tutorial, we will show you How to Add a Linux User With Document Root Permissions.

Root is the username or account that by default has access to all commands and files on a Linux or other Unix-like operating system. It is also referred to as the root account, root user, and the superuser.

CentOS, Fedora, and RHEL

In CentOS, Fedora, and RHEL Apache is located at /var/www/html.

The first thing to do is to create a user by running this command:

sudo useradd -d /var/www/html -G apache vpsiedemo

After creating set one password.To set it run this command:

sudo passwd vpsiedemo

If you want to modify one existing user run this command:
sudo usermod -a -G apache vpsiedemo

To set the group run:
sudo chgrp -R apache /var/www/html

To set the permissions run:
sudo chmod -R g+w /var/www/html
sudo chmod g+s /var/www/html

Ubuntu and Debian

In Ubuntu and Debian Apache is located at /var/www.

Create a user for Ubuntu and Debian by running this command:

sudo useradd -d /var/www -G www-data vpsiedemo

To set password is same as in CentOS, Fedora, and RHEL.

sudo passwd vpsiedemo

If you want to modify one existing user run:

sudo usermod -a -G www-data vpsiedemo

To set the group run:

sudo chgrp -R www-data /var/www

And to set the permissions run:

sudo chmod -R g+w /var/www
sudo chmod g+s /var/www

You have successfully Add a Linux User With Document Root Permissions.

Enjoy!

Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Unlock Your

20% Discount

The First 3 orders get 20% discount! Try Sign up on VPSie to get a chance to get the discount.