Abhinandan's Blog
ABHINANDAN ARYAL

anudwigna[at]gmail.com

HOME

Management of Users in Ubuntu 18.04

Apr 28, 2020

Ubuntu Linux

Management of Users in Linux systems is one of the most important task. It is always safe to create a secondary user besides "root" so that all the actions taken can be reverted. However, we can always give privileges to our newly created user so that he/she can perform any super user task.

Note: Must be logged in as root in order to manage the users unless the management privilege is given to the user.

Adding an User

In order to add user, run the following command:

=> If signed in as root

adduser <the-username-of-the-user>

=> if you have the right priviliges and not signed in as root

sudo adduser <the-username-for-the-user>

You will be asked a series of Questions. Lastly, confirm all the provided information is correct and you have your user created. Now, your new user is ready to use. You can logout from your current user and test it with the recently created username and password.

Now, if you want to give the administrative rights to the newly created user, please read below.

First run the following command:

=> if signed in as root

visudo

=>if signed in as user other than root

sudo visudo

Nano will open the file /etc/sudoers Find the following line in the file:

root ALL=(ALL:ALL) ALL

Below the line add a new line with your username like this:

<the-username-of-the-user> ALL=(ALL:ALL) ALL

Save the file by pressing Ctrl + O in nano editor and exit by pressing Ctrl + X .

Now you have your new user with administrative rights. Now you have your new user with administrative rights.

Deleting User

You can delete the user by issuing the following command:

=> if signed in as root

sudo deluser <the-username-of-the-user>

=>if signed in as user other than root

deluser <the-username-of-the-user>

Also you can delete the home directory of the User while removing them by issuing the following command:

=> if signed in as root

deluser --remove-home newuser

=> if signed in as user other than root

sudo deluser --remove-home newuser

Also don't forget to remove the line we added earlier in /etc/sudoers file.