Managing Users and Groups on a Linux system can be rather cumbersome for new users so today I’m going to go over how to create, delete, and edit Users and Groups. There are a couple of different ways to manage users and groups so we’re going to look at the easier ways for now.
Users
Create a new user with the login name of codedrunk:
# sudo adduser codedrunk
The new user accoung will be created and added to it’s own usergroup (same as the user name), you will be prompted to enter a password, and you will be prompted to enter optional information.
So now we have our new user created but we need to add it to a different group. For example I want this new account to have administrative privileges on an Ubuntu server so I will add it to the admin group:
# sudo usermod -a -G admin codedrunk
Our new account is now created and added to the admin group. If you no longer need this account and want to delete it use this command:
# sudo deluser codedrunk
The user account will be removed and if this was the last member of a created group as ours was, the group will also be removed. Empty system groups will not be removed.
Groups
Managing groups is just as easy as managing users. First off lets make a new group called goodgroup:
# sudo groupadd goodgroup
Now we’ll add a user to the new group:
# sudo usermod -a -G goodgroup Username
To remove the group:
# sudo groupdel goodgroup
And finally to see what groups a user belongs to you can use this command:
# sudo groups useraccount
Thats it for Users and Groups. Tomorrow we’ll take a quick look at the resolv.conf file which points your system to DNS servers.