Author: Eiko

Time: 2024-10-28 10:12:58 - 2024-10-28 10:14:46 (UTC)

This note will cover the essential commands to manage machines with multiple users that need to work on the same project owo

Create Users and Groups

Create a User

sudo useradd -m username

Create a group for the project which the user will work on

sudo groupadd groupname

Add the user to the group

sudo usermod -aG groupname username

optional: set the user’s password

sudo passwd username

Set Permissions

make your project directory in /var/www/html or /opt

sudo mkdir /var/www/html/projectname

Change the group of the project directory to the group you created

sudo chown -R :groupname /var/www/html/projectname
# or use chgrp
sudo chgrp -R groupname /var/www/html/projectname
# -R is for recursively applying the changes to all files and directories inside the project directory
sudo chmod -R 775 /var/www/html/projectname

Group Permissions

Depending on your situation you might need to give read write access to the owner or group. You can do it by chmod g+rw here g means group, rw means read and write. Similarly x means execution.

chmod rw -R /project/path   # For the owner
chmod g+rw -R /project/path # For the group