Entries Tagged 'Unix users' ↓

getent - get entries from administrative database

Hi! If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

getent is Unix command which helps you query one of the following administrative databases in Unix: passwd, group, hosts, services, protocols, or networks.

Administrative databases in Unix

As you can probably see from their names, the administrative databases are here to help you gather the most vital information about your environment:

  • passwd - can be used to confirm usernames, userids, home directories and full names of your users
  • group - all the information about Unix groups known to your system
  • services - all the Unix services configured on your system
  • networks - networking information - what networks your system belongs to
  • protocols - everything your system knows about network protocols

How to use getent

My home PC has a hostname of ubuntu. If I ever need to double-check which IPs this hostname points to, here's how I can use getent:

ubuntu$ getent hosts ubuntu
127.0.1.1       ubuntu
192.168.0.2     ubuntu

Using getent to find a UID by username

getent accepts various keys when searching in databases. For the passwd one, you can user either username or user id (UID) to search the database.

ubuntu$ getent passwd greys
greys:x:1000:1000:Gleb Reys,,,:/home/greys:/bin/bas

Using getent to find a username by UID

Like I said, the opposite will work as well:

ubuntu$ getent passwd 1000
greys:x:1000:1000:Gleb Reys,,,:/home/greys:/bin/bash

See also:

  • id - print user identity
  • who - see who is logged into the system

id - print Unix user identity

id command is one of the basic unix commands, and it servers a very simple purpose of confirming the identity of a specified Unix user.

Simplest way to use the id command

All you do is just type id in your command line prompt, and it then gets back to you with confirmations of your own user id, group id, and a list of other groups you're a member of:

ubuntu$ id
uid=1000(greys) gid=113(admin) groups=33(www-data),113(admin)

Continue reading →

who - find out who is on the system

who is one of basic Unix commands, which allows you to quickly see who else is logged in.

who - default behaviour

When you run who without any parameters, it returns you a list of users on your Unix system, along with terminals they're using, the time of the start for each session, and the hostnames where these users are logged in from.

Continue reading →