How to list all Users and Human Users in terminal on Ubuntu

You don’t need to use any GUI applications to show all your users on your system . You can do it via your terminal command-line application. You can list all system generated and human created or normal Linux users via the below commands. Lots of options are available. Just try all commands in your terminal and find the difference. If any other options available please mention in comments.

 

List all users on Ubuntu:

cat /etc/passwd
getent passwd
less /etc/passwd
more /etc/passwd

Below commands shows only the users name only.

compgen -u
cut -d: -f1 /etc/passwd
awk -F':' '{ print $1}' /etc/passwd

List all Human or Normal users on Ubuntu:

cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1
awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd

Below hack is not a correct method but it will work on most situations.

getent passwd $(ls /home) | grep -o '^[^:]*'
ls /home
If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Also Read:  Pocket Broomball Winter Sport Game

Leave a Reply