Get Linux User Info

It's never good if we could not obtain user information from the Linux OS. This section guides you on how to get Linux user information from the Linux operating system.

Get User Information

There are 2 ways to get the user information.

List All Users

In this case, you can list all the users available in the system. The command is:

$ getent passwd

Depending on execution permission, this will return not just the user created account but also system level groups like nobody or root. Also, you notice that each users has some comma information. The return value can be:

testo:x:1001:1001:Testo,0,012-3456789,03-45678912,supervisor floor B1:/home/testo:/bin/bash

This is interpreted as:

  • user name = testo
  • password field = x
  • user specific group ID = 1001
  • user group ID = 1001
  • full name = Testo
  • room number = 0
  • work phone = 012-3456789
  • home phone = 03-45678912
  • Other = supervisor floor B1
  • Home directory = /home/testo
  • Login executable = /bin/bash

Get Specific User

In this case, you can get specific user from the list query. The command is:

$ getent passwd | grep "<name / username / query info>"

This will query the specific user from the list using your keywords.

That's all for getting user info from an Linux operating system.