How to List All Users in Linux

Linux Get List Of Users

tl;dr - The first column on each line of file /etc/passwd is the list of all Linux users

In order to find out the list of users present on your Linux Operating System you need to check out the /etc/passwd file

You can simply open the etc/passwd in editor like vim or nano, or simply can cat the text out on the console.

bash-4.2# cat /etc/passwd 

ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin

For better readability, let us use the sed tool and replace colon with tab,

# sed 's/:/\t/g' /etc/passwd
root	x	0	0	root	/root	/bin/bash
bin	x	1	1	bin	/bin	/sbin/nologin
daemon	x	2	2	daemon	/sbin	/sbin/nologin
adm	x	3	4	adm	/var/adm	/sbin/nologin
lp	x	4	7	lp	/var/spool/lpd	/sbin/nologin
sync	x	5	0	sync	/sbin	/bin/sync
shutdown	x	6	0	shutdown	/sbin	/sbin/shutdown
halt	x	7	0	halt	/sbin	/sbin/halt
mail	x	8	12	mail	/var/spool/mail	/sbin/nologin
operator	x	11	0	operator	/root	/sbin/nologin
games	x	12	100	games	/usr/games	/sbin/nologin
ftp	x	14	50	FTP User	/var/ftp	/sbin/nologin
nobody	x	99	99	Nobody	/	/sbin/nologin

Now the output looks much more readable, the first column that you see is users.

Example: details of root user

  1. Username/Login User: root
  2. Encrypted Password: x (x -> stored in file /etc/shadow)
  3. User ID: 0
  4. Group ID: 0
  5. User Description: root
  6. User’s home directory: /root
  7. User’s Login Shell: /bin/bash

Have Questions? Post them here!

Topics Coverage:

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram