How to create a new user in Linux and add it to a group


Full article


The idea is to organize user management in ubuntu in a simple way so just by looking at it, you are able to know what to do.

Getting Started:

Create User

sudo adduser yourname

Change User password

sudo passwd user

Delete User

sudo deluser yourname

Deleting the user account doen't remove the respective home folder. It's up to you whether or not you wish to delete the folder manually or keep it.

Remember, any user added later on with the same UID/GID as the previous owner will now have access to this folder if you have not taken the necessary precautions.

Move deleted User to archived folder

If you'd like to change that, so you can have an achieved folder for those who you deleted, you can do the following to avoid future conflicts:

sudo chown -R root:root /home/username/
sudo mkdir /home/archived_users/
sudo mv /home/username /home/archived_users/

Temporarily lock or unlock a user account

Lock: sudo passwd -l username
Unlock: sudo passwd -u username

Show Groups


Add or Delete a Group

Add: sudo addgroup groupname
Delete: sudo delgroup groupname

Add User to Group

sudo adduser username groupname