sudo usermod -a -G group username
usermod -a -G examplegroup exampleusername
usermod -a -G groupname username
sudo usermod -aG <groups> <username>
sudo usermod -aG groupName userName
# restart or just run
newgrp groupName
sudo usermod -a -G GROUP USER
sudo groupadd $GROUP
sudo usermod -aG $GROUP $USER
useradd -mg [groups] [username]
sudo dseditgroup -o edit -t user -a <user> <group> # OSX
groups $username
chown USER:GROUP FILE
usermod -a -G <group> <user>
$ usermod -a -G developer tom
User: the owner of the file (person who created the file).
Group:the group can contain multiple users. Therefore, all users in that group will have the same permissions. It makes things easier than assign permission for every user you want.
#!/bin/bash
while [ x$username = "x" ]; do
read -p "Please enter the username you wish to create : " username
if id -u $username >/dev/null 2>&1; then
echo "User already exists"
username=""
fi
done
while [ x$group = "x" ]; do
read -p "Please enter the primary group. If group not exist, it will be created : " group
if id -g $group >/dev/null 2>&1; then
echo "Group exist"
else
groupadd $group
fi
done
read -p "Please enter bash [/bin/bash] : " bash
if [ x"$bash" = "x" ]; then
bash="/bin/bash"
fi
read -p "Please enter homedir [/home/$username] : " homedir
if [ x"$homedir" = "x" ]; then
homedir="/home/$username"
fi
read -p "Please confirm [y/n]" confirm
if [ "$confirm" = "y" ]; then
useradd -g $group -s $bash -d $homedir -m $username
fi