Add and remove Linux users using the terminal

Nowadays the GUI interface on any desktop Linux distribution is so advanced that the average user can fulfill any task without any difficulty; still, the old command line allows us to speed up any of such activity because it allows us to give direct commands instead of navigating through thousand windows and options.

For example, lets examine the following commands for adding and removing an user account from the command line.

Add a user
First open a terminal and give the following command to create a new user account (of course replace username with the name of the user account you want to create):
sudo useradd username

Now we create a home directory:
sudo mkdir /home/username

And set a password:
sudo passwd username

Finally, assign to the user the ownership of his home directory:
sudo chown username /home/username
sudo chgrp username /home/username

If you want, then you can assign administrator privileges to the account you just created with the following command:
sudo adduser username sudo

Removing a user
If the goal is to delete a user, the process is even easier:
sudo userdel username
sudo rm -r /home/username/