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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright Β© Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap