Each Operating System has its own environment that a user needs to understand. Linux is a very powerful OS as compared to others. In this article, we gonna learn about the Best Ways to “List Linux Users”. All the methods are purely true and tested by our team.
Navigation to Contents
List Linux Users:
- Using
less /etc/passwd
to list users.
This command will help you to list the locally stored users in the system. After you’ve used the command it will give output as:
root:!:0:0::/:/usr/bin/ksh
daemon:!:1:1::/etc:
bin:!:2:2::/bin:
sys:!:3:3::/usr/sys:
adm:!:4:4::/var/adm:
uucp:!:5:5::/usr/lib/uucp:
guest:!:100:100::/home/guest:
nobody:!:4294967294:4294967294::/:
lpd:!:9:4294967294::/:
lp:*:11:11::/var/spool/lp:/bin/false
invscout:*:200:1::/var/adm/invscout:/usr/bin/ksh
nuucp:*:6:5:uucp login user:/var/spool/uucppublic:/usr/sbin/uucp/uucico
paul:!:201:1::/home/paul:/usr/bin/ksh
jdoe:*:202:1:John Doe:/home/jdoe:/usr/bin/ksh
The output format is as follows:
- Username
- Password(encrypted: you won’t be able to see)
- UID
- GID
- Full Name
- The home directory of a particular user.
- Using
compgen
This command helps you to list all the users without any further information. “compgen” is used with -u command. eg,
compgen -u
The output will be very simple like,
Suyash
Techeverywhere
Hero
Admin
- List the Usernames.
I have already told you about “compgen” command. There is another way to do the same thing.cut -d: -f1 /etc/passwd
This will too, give you simple usernames without any further instance of the users.
root
user
admin
hero
shaktiman
linuxuser3
yourname
Latest:
- Namecheap Hosting Review.
- How to install Kali Linux on VMware.
- How to buy parts for Gaming PC in 2019
- Best Web Hosting Providers in 2019
-
- List Users using Gatent Command:
It will give you a detailed output as I’ve shown in “less /etc/passwd“. Example,
root:!:0:0::/:/usr/bin/ksh
daemon:!:1:1::/etc:
bin:!:2:2::/bin:
sys:!:3:3::/usr/sys:
adm:!:4:4::/var/adm:
uucp:!:5:5::/usr/lib/uucp:
guest:!:100:100::/home/guest:
nobody:!:4294967294:4294967294::/:
lpd:!:9:4294967294::/:
lp:*:11:11::/var/spool/lp:/bin/false
invscout:*:200:1::/var/adm/invscout:/usr/bin/ksh
nuucp:*:6:5:uucp login user:/var/spool/uucppublic:/usr/sbin/uucp/uucico
paul:!:201:1::/home/paul:/usr/bin/ksh
jdoe:*:202:1:John Doe:/home/jdoe:/usr/bin/ksh
How to check existing users?
It is very simple to identify existing users. Just use the following command,
johndoe:x:1000:1000:John Doe,,,:/home/johndoe:/bin/bash
It will give you the output with all the details of the users if it exists.
Follow me on Instagram to support my work: