To see all users in Linux, you can check the contents of the /etc/passwd file โ this file stores information about all user accounts.
๐งพ Show All Users
cat /etc/passwd
This will show a list of all users in this format:
username:x:UID:GID:comment:home_directory:shell
If you want just the usernames, run:
cut -d: -f1 /etc/passwd
๐ฅ To Show Only Human Users (not system users)
Most human users have a UID โฅ 1000 (except for root which is UID 0). You can filter like this:
awk -F: '$3 >= 1000 && $3 != 65534 { print $1 }' /etc/passwd
65534is typically thenobodyuser.
๐ To See Logged-In or Recently Active Users
- Current users logged in:
who - Show login history:
last