getent

Linux · Users and permissions · reference only

What it does

Queries the system databases (users, groups, hosts, services) honouring the configured sources, not just local files.

Syntax

getent [opciones] base_de_datos [clave...]

Options and parameters

  • passwd

    User database, equivalent to /etc/passwd.

  • group

    Group database, equivalent to /etc/group.

  • hosts

    Resolves host names using /etc/hosts and DNS.

  • services

    Looks up the ports tied to services, as in /etc/services.

  • -s fuente

    Restricts the lookup to one source from nsswitch.conf.

  • -i

    Disables conversion of internationalized domain names.

Usage examples

  • getent passwd ana

    Shows the passwd line for the ana account.

  • getent group sudo

    Shows the GID and members of the sudo group.

  • getent hosts example.com

    Resolves example.com the way the system would.

  • getent passwd | cut -d: -f1

    Lists every account name, including LDAP or SSSD ones.

Notes and common mistakes

  • It follows /etc/nsswitch.conf, which is why it finds users that are not in /etc/passwd.

Related commands