In Ubuntu and other Debian based distributions, “adduser” package is used for account management.
- To add a user account, use the following syntax, and follow the prompts to give the account a password and identifiable characteristics such as a full name, phone number, etc.
sudo adduser username
- To delete a user account and its primary group, use the following syntax:
sudo deluser username
Deleting an account doesn’t remove the home folder for that account. If an account with same username( UID/GID) is created later, that account owner will now have access to this folder if you have not taken the necessary precautions.
You can remove that folder or move to different folder (relocate) to prevent this unnecessary data access and conflicts.
For relocating follow the command (recommended),
sudo chown -R root:root /home/username/ sudo mkdir /home/archived_users/ sudo mv /home/username /home/archived_users/
For removing that folder follow the command (not recommended, take extra care on remove,it cannot be undone),
sudo rm -r /home/username/
- To temporarily lock or unlock a user account, use the following syntax, respectively:
sudo passwd -l username sudo passwd -u username
- To add or delete a personalized group, use the following syntax, respectively:
sudo addgroup groupname sudo delgroup groupname
- To add a user to a group, use the following syntax:
sudo adduser username groupname