How to List All Users in Ubuntu? | Add, Delete & Modify

A system can have multiple users with personal space and user accounts which is the same case with Linux, where you can create a total of “4294967296” users. User management is one of the crucial duties of a system administrator that involves adding, deleting, and modifying the accounts for a better environment in the workplace.

The purpose of this guide is to teach our audience about user management, which will cover the following aspects.

Let’s start with the listing method first!

How to List All Users in Ubuntu?

Ubuntu is one of the most widely used Linux distributions due to the features it packs, and one of them is user management. The first step to managing the users is to view the list of users using either of the two methods mentioned below.

  • List Users with cat Command
  • List Users with awk Command

Let’s discuss these methods in detail in the next section.

Using the cat Command

The cat command can display every text file on your system and list the users; we’ll open the “/etc/passwd” file using this command.

$ cat /etc/passwd

Using the cat command, the list of users is displayed as seen above, and it goes on (line 50 in our case.)

Using awk Command

Some users may find it disturbing to go through the cat command’s output with all that irrelevant information. So here we have the awk command that displays only the user names, as seen below when this command is used.

$ awk -F':' '{ print $1}' /etc/passwd

See the above result of the “awk command,” no confusion there, I guess. Now we’ll move more to the next section.

How to Add Users in Ubuntu?

Adding users in Ubuntu is done through two methods: the following.

  • Adding Users via Terminal
  • Adding Users via GUI

Let’s discuss the above two methods in detail below.

Add Users via Terminal

Adding new users on Ubuntu through the terminal requires the execution of this command:

$ sudo adduser <User-Name>

Also, usernames are case sensitive, so if you want to create a user with a capital letter, then you need to write the following command:

$ sudo adduser <User-Name> --force-badname

After entering the required information like password, Full Name, and other relevant information, a new user will be created.

Add Users Via GUI

Novice users mainly prefer the GUI or graphical user interface, and adding new users is relatively easy. To change the password, open the search bar through the activities icon as shown below:

A new popup menu will appear where you must type “Users”, and a user settings option will appear; open it, as seen below.

Now unlock your account by clicking on the “unlock button” for security reasons, you’d be asked to enter the password.

After entering your password, you can click on the “Authenticate” button to unlock the “add user” button.

While creating a new user, you’ll need to select the account type and add the user name and password; you can set it now or let the new user do it on the next login.

Now that you’ve created a new user for Ubuntu, the next section will explain how to delete users.

How to Delete Users in Ubuntu?

You can delete the users in Ubuntu by using either one of these methods.

  • Delete Users Via Terminal
  • Delete Users Via GUI

Let’s discuss them in detail below.

Delete Users Via Terminal

Use this command to delete only the user account but not the user files.

$ sudo deluser [User-Name]

Now, to delete the user along with the data, there is a slight change in the above command which is the “–remove-home” flag. The command is used like this.

$ sudo deluser --remove-home [User-Name]

By executing the “deluser” command with “–remove-flag”, the user and the user data are removed.

Delete Users Via GUI

To delete the users through the GUI in Linux, you’ll need to navigate to the user’s settings and unlock the account, as discussed in the above section.

Once the currently logged-in account is unlocked, select the user account to delete, as seen below.

You’ll now be asked if you want to keep the files of the user being deleted; choose accordingly.

And finally, the user is removed from your system, so we’ll move to the next section: Modifying user accounts.

How to Modify Users in Ubuntu?

Ubuntu has the flexibility to give its users the functionality to modify their user accounts, and we’ll cover the following.

  • Update the password
  • Give a user the root privileges

How to Update the User Password in Ubuntu?

To update the user password in Linux, there are two methods which are as follows.

Using Terminal

To change the password of a specific user, use this command.

$ sudo passwd [User-Name]

The system administrator can change the password in case of an event that requires it, as seen in the above image.

Using GUI

Changing user accounts requires unlocking the user settings, which is explained in the first section of his guide.

Once the settings are unlocked for the current user, the password can be changed by clicking on the password button, as seen below.

 A popup window will now open where you must select options as per your choice, either setting the password on the next login or doing it now.

That is how you can change the user password in Ubuntu, and the next section is for giving the user root privileges.

How to Give a User the Root Privileges?

To grant a user with the root privileges, the “/etc/passwd” file needs to be edited, where you need to find the username and change the values to 0:0, as seen below.

$ sudo nano /etc/passwd

And there, the guest user has the root privileges. We’ve changed these values of GID & UID, and setting them to 0,0 means root access.

Conclusion

User management is one of the most crucial tasks of a system administrator who can list, add, delete or modify users in Ubuntu which is thoroughly explained in this guide. Regular users can work their way around by changing their passwords.