How to view all users in Linux
In Linux, you can use the following command to view all users:
- display the content of the file /etc/passwd
cat /etc/passwd
- Extract the first field from the /etc/passwd file using a delimiter of “:”.
cut -d: -f1 /etc/passwd
- Retrieve user information
getent passwd
- Extract the first field from the /etc/passwd file using the delimiter “:”
awk -F: '{print $1}' /etc/passwd
These commands can be executed in the terminal to view information of all users in the system.