Add a new user
# Add a user
sudo useradd user1
# Add a user AND create HOME (/home/user1) directory
sudo useradd --create-home user1
# Add a password for user 1
sudo passwd user1
# Add user Interactively
sudo adduser user2
Code language: PHP (php)
Manage Groups
# Add or Delete Groups
sudo addgroup groupname
sudo delgroup groupname
# Add user to a group
sudo usermod -a -G groupname user1
# list groups
getent group
less /etc/group
# All groups of a User
groups user1
id user1
# All users of a group
getent group sudo
Code language: PHP (php)