![list users in Ubuntu](https://techpiezo.com/wp-content/uploads/2022/09/list-users-in-Ubuntu.webp)
When there are multiples users accessing the same system. Then, it becomes crucial to manage system resources. In addition to, we can’t let all users have the access to all of system resources. So, it’s System Administrator’s call to decide who gets what. But, before that a System Administrator should know about all the users who have access to the system. So, in this article, we cover how to list users in Ubuntu.
There are multiple ways to list the users in Ubuntu. Couple of those we discuss here, would lead to similar outcomes. Just that the methods chosen are different.
First of those method is through cat and the other one getent command-line utility. None of the methods discussed below require superuser privileges.
list users in Ubuntu
Method I. Just open a terminal and issue the following –
cat /etc/passwd
We have used cat to print on standard Output. It would return with a list of users –
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
root, daemon here are the usernames. We have just covered two of those entries here. You would get different output depending on the number of users on your system.
Method II. As already discussed similar outcomes can be achieved through getent command-line utility. Just, issue the following in terminal –
getent passwd
You would get pretty similar outcome. getent mainly looks for information in files which are present in configuration file – /etc/nsswitch.conf
So, if you do –
cat /etc/nsswitch.conf
There is list of files available there. Try running any of those and check the outcome. For instance,
getent protocols
In conclusion, we have covered here how to list users in Ubuntu. It is better to know all the users who currently have the access to the system. So, if some users choose not to access the system later then we can either modify user privileges or entirely remove them. Since, this article mainly dealt with listing users. Therefore, we chose not to cover /etc/passwd
file much. We do that in subsequent articles.