---
name: "getent"
section: "1"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "openbsd"]
url: "https://new.carta.tech/getent"
---

# getent(1)

get entries from administrative database

## NAME

**getent** – get entries from administrative database

## SYNOPSIS

**getent** *database* \[*key* *...*\]

## DESCRIPTION

The **getent** utility retrieves and displays entries from the administrative database specified by *database*, using the lookup order specified in [nsswitch.conf(5)](/nsswitch.conf/5.md). The display format for a given *database* is as per the “traditional” file format for that database.

The *database* argument may be one of:

| | |
| --- | --- |
| ethers | address name |
| group | group:passwd:gid:\[member\[,member\]...\] |
| hosts | address name \[alias ...\] |
| netgroup | (host,user,domain) \[...\] |
| networks | name network \[alias ...\] |
| passwd | user:passwd:uid:gid:gecos:home\_dir:shell |
| protocols | name protocol \[alias ...\] |
| rpc | name number \[alias ...\] |
| services | name port/protocol \[alias ...\] |
| shells | /path/to/shell |
| utmpx | \[time\] type: properties |

**Database** 	 **Display** **format**

If one or more *key* arguments are provided, they will be looked up in *database* using the appropriate function. For example, “passwd” supports a numeric UID or user name; “hosts” supports an IPv4 address, IPv6 address, or host name; and “services” supports a service name, service name/protocol name, numeric port, or numeric port/protocol name.

If no *key* is provided and *database* supports enumeration, all entries for *database* will be retrieved using the appropriate enumeration function and printed.

## EXIT STATUS

The **getent** utility exits 0 on success, 1 if there was an error in the command syntax, 2 if one of the specified key names was not found in *database*, or 3 if there is no support for enumeration on *database*.

## EXAMPLES

Show entry for user sshd from the passwd database:

```
$ getent passwd sshd
sshd:*:22:22:Secure Shell Daemon:/var/empty:/usr/sbin/nologin
```

Show entry for TCP from the protocols database:

```
$ getent protocols tcp
tcp                   6  TCP
```

Show entry for the localhost IPv6 address ::1 from the hosts database:

```
$ getent hosts ::1
::1               localhost  localhost.my.domain
```

## SEE ALSO

[getutxent(3)](/getutxent/3.md), [ethers(5)](/ethers/5.md), [group(5)](/group/5.md), [hosts(5)](/hosts/5.md), [netgroup(5)](/netgroup/5.md), [networks(5)](/networks/5.md), [nsswitch.conf(5)](/nsswitch.conf/5.md), [passwd(5)](/passwd/5.md), [protocols(5)](/protocols/5.md), [rpc(5)](/rpc/5.md), [services(5)](/services/5.md), [shells(5)](/shells/5.md)

## HISTORY

A **getent** command appeared in NetBSD 3.0, and was imported into FreeBSD 7.0. It was based on the command of the same name in Solaris and Linux.
