{
    "mode": "man",
    "parameter": "getent",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/getent/1/json",
    "generated": "2026-06-12T13:42:18Z",
    "synopsis": "getent [option]... database key...",
    "sections": {
        "NAME": {
            "content": "getent - get entries from Name Service Switch libraries\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "getent [option]... database key...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  getent  command displays entries from databases supported by the Name Service Switch li‐\nbraries, which are configured in /etc/nsswitch.conf.  If one or more key arguments  are  pro‐\nvided,  then  only the entries that match the supplied keys will be displayed.  Otherwise, if\nno key is provided, all entries will be displayed (unless the database does not support  enu‐\nmeration).\n\nThe database may be any of those supported by the GNU C Library, listed below:\n\nahosts    When  no key is provided, use sethostent(3), gethostent(3), and endhostent(3) to\nenumerate the hosts database.  This is identical to using hosts.   When  one  or\nmore  key  arguments are provided, pass each key in succession to getaddrinfo(3)\nwith the address family AFUNSPEC, enumerating each socket address structure re‐\nturned.\n\nahostsv4  Same as ahosts, but use the address family AFINET.\n\nahostsv6  Same as ahosts, but use the address family AFINET6.  The call to getaddrinfo(3)\nin this case includes the AIV4MAPPED flag.\n\naliases   When no key is provided, use setaliasent(3), getaliasent(3), and  endaliasent(3)\nto enumerate the aliases database.  When one or more key arguments are provided,\npass each key in succession to getaliasbyname(3) and display the result.\n\nethers    When one or more key arguments are provided, pass  each  key  in  succession  to\netheraton(3)  and  etherhostton(3) until a result is obtained, and display the\nresult.  Enumeration is not supported on ethers, so a key must be provided.\n\ngroup     When no key is provided, use setgrent(3), getgrent(3), and endgrent(3)  to  enu‐\nmerate  the  group  database.  When one or more key arguments are provided, pass\neach numeric key to getgrgid(3) and each nonnumeric key to getgrnam(3) and  dis‐\nplay the result.\n\ngshadow   When  no  key is provided, use setsgent(3), getsgent(3), and endsgent(3) to enu‐\nmerate the gshadow database.  When one or more key arguments are provided,  pass\neach key in succession to getsgnam(3) and display the result.\n\nhosts     When  no key is provided, use sethostent(3), gethostent(3), and endhostent(3) to\nenumerate the hosts database.  When one or more key arguments are provided, pass\neach  key  to gethostbyaddr(3) or gethostbyname2(3), depending on whether a call\nto inetpton(3) indicates that the key is an IPv6 or IPv4 address  or  not,  and\ndisplay the result.\n\ninitgroups\nWhen one or more key arguments are provided, pass each key in succession to get‐‐\ngrouplist(3) and display the result.  Enumeration  is  not  supported  on  init‐‐\ngroups, so a key must be provided.\n\nnetgroup  When  one  key  is  provided,  pass the key to setnetgrent(3) and, using getnet‐‐\ngrent(3) display the resulting string triple (hostname,  username,  domainname).\nAlternatively,  three  keys  may be provided, which are interpreted as the host‐\nname, username, and domainname to match to a netgroup name via innetgr(3).  Enu‐\nmeration  is not supported on netgroup, so either one or three keys must be pro‐\nvided.\n\nnetworks  When no key is provided, use setnetent(3),  getnetent(3),  and  endnetent(3)  to\nenumerate  the  networks database.  When one or more key arguments are provided,\npass each numeric key to getnetbyaddr(3) and each nonnumeric  key  to  getnetby‐‐\nname(3) and display the result.\n\npasswd    When  no  key is provided, use setpwent(3), getpwent(3), and endpwent(3) to enu‐\nmerate the passwd database.  When one or more key arguments are  provided,  pass\neach  numeric key to getpwuid(3) and each nonnumeric key to getpwnam(3) and dis‐\nplay the result.\n\nprotocols When no key is provided, use setprotoent(3), getprotoent(3), and  endprotoent(3)\nto  enumerate  the  protocols database.  When one or more key arguments are pro‐\nvided, pass each numeric key to getprotobynumber(3) and each nonnumeric  key  to\ngetprotobyname(3) and display the result.\n\nrpc       When  no  key  is  provided, use setrpcent(3), getrpcent(3), and endrpcent(3) to\nenumerate the rpc database.  When one or more key arguments are  provided,  pass\neach numeric key to getrpcbynumber(3) and each nonnumeric key to getrpcbyname(3)\nand display the result.\n\nservices  When no key is provided, use setservent(3), getservent(3), and endservent(3)  to\nenumerate  the  services database.  When one or more key arguments are provided,\npass each numeric key to getservbynumber(3) and  each  nonnumeric  key  to  get‐‐\nservbyname(3) and display the result.\n\nshadow    When  no  key is provided, use setspent(3), getspent(3), and endspent(3) to enu‐\nmerate the shadow database.  When one or more key arguments are  provided,  pass\neach key in succession to getspnam(3) and display the result.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-s --service",
                    "content": "Override all databases with the specified service.  (Since glibc 2.2.5.)\n",
                    "flag": "-s",
                    "long": "--service"
                },
                {
                    "name": "-s --service",
                    "content": "Override  only specified databases with the specified service.  The option may be used\nmultiple times, but only the last service for each  database  will  be  used.   (Since\nglibc 2.4.)\n",
                    "flag": "-s",
                    "long": "--service"
                },
                {
                    "name": "-i --no-idn",
                    "content": "Disables IDN encoding in lookups for ahosts/getaddrinfo(3) (Since glibc-2.13.)\n\n-?, --help\nPrint a usage summary and exit.\n",
                    "flag": "-i",
                    "long": "--no-idn"
                },
                {
                    "name": "--usage",
                    "content": "Print a short usage summary and exit.\n",
                    "long": "--usage"
                },
                {
                    "name": "-V --version",
                    "content": "Print the version number, license, and disclaimer of warranty for getent.\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "One of the following exit values can be returned by getent:\n\n0      Command completed successfully.\n\n1      Missing arguments, or database unknown.\n\n2      One or more supplied key could not be found in the database.\n\n3      Enumeration not supported on this database.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "nsswitch.conf(5)\n",
            "subsections": []
        },
        "COLOPHON": {
            "content": "This  page  is  part  of  release  5.10 of the Linux man-pages project.  A description of the\nproject, information about reporting bugs, and the latest version of this page, can be  found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-12-21                                    GETENT(1)",
            "subsections": []
        }
    },
    "summary": "getent - get entries from Name Service Switch libraries",
    "flags": [
        {
            "flag": "-s",
            "long": "--service",
            "arg": null,
            "description": "Override all databases with the specified service. (Since glibc 2.2.5.)"
        },
        {
            "flag": "-s",
            "long": "--service",
            "arg": null,
            "description": "Override only specified databases with the specified service. The option may be used multiple times, but only the last service for each database will be used. (Since glibc 2.4.)"
        },
        {
            "flag": "-i",
            "long": "--no-idn",
            "arg": null,
            "description": "Disables IDN encoding in lookups for ahosts/getaddrinfo(3) (Since glibc-2.13.) -?, --help Print a usage summary and exit."
        },
        {
            "flag": "",
            "long": "--usage",
            "arg": null,
            "description": "Print a short usage summary and exit."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Print the version number, license, and disclaimer of warranty for getent."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "nsswitch.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/nsswitch.conf/5/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Get entries from Name Service Switch libraries.",
        "examples": [
            {
                "description": "Get list of all groups",
                "command": "getent group"
            },
            {
                "description": "See the members of a group",
                "command": "getent group {{group_name}}"
            },
            {
                "description": "Get list of all services",
                "command": "getent services"
            },
            {
                "description": "Find a username by UID",
                "command": "getent passwd 1000"
            },
            {
                "description": "Perform a reverse DNS lookup",
                "command": "getent hosts {{host}}"
            }
        ]
    }
}