man-pages/man1/getent.1.html
2021-03-31 01:06:50 +01:00

598 lines
12 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GETENT</TITLE>
</HEAD><BODY>
<H1>GETENT</H1>
Section: User Commands (1)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
getent - get entries from Name Service Switch libraries
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>getent&nbsp;[</B><I>option</I>]...&nbsp;<I>database</I>&nbsp;<I>key</I>...
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>getent</B>
command displays entries from databases supported by the
Name Service Switch libraries,
which are configured in
<I>/etc/nsswitch.conf</I>.
If one or more
<I>key</I>
arguments are provided,
then only the entries that match the supplied keys will be displayed.
Otherwise, if no
<I>key</I>
is provided, all entries will be displayed (unless the database does not
support enumeration).
<P>
The
<I>database</I>
may be any of those supported by the GNU C Library, listed below:
<DL COMPACT><DT id="1"><DD>
<DL COMPACT>
<DT id="2"><B>ahosts</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+sethostent">sethostent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+gethostent">gethostent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endhostent">endhostent</A></B>(3)
to enumerate the hosts database.
This is identical to using
<B>hosts</B>.
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
in succession to
<B><A HREF="/cgi-bin/man/man2html?3+getaddrinfo">getaddrinfo</A></B>(3)
with the address family
<B>AF_UNSPEC</B>,
enumerating each socket address structure returned.
<DT id="3"><B>ahostsv4</B>
<DD>
Same as
<B>ahosts</B>,
but use the address family
<B>AF_INET</B>.
<DT id="4"><B>ahostsv6</B>
<DD>
Same as
<B>ahosts</B>,
but use the address family
<B>AF_INET6</B>.
The call to
<B><A HREF="/cgi-bin/man/man2html?3+getaddrinfo">getaddrinfo</A></B>(3)
in this case includes the
<B>AI_V4MAPPED</B>
flag.
<DT id="5"><B>aliases</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setaliasent">setaliasent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getaliasent">getaliasent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endaliasent">endaliasent</A></B>(3)
to enumerate the aliases database.
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
in succession to
<B><A HREF="/cgi-bin/man/man2html?3+getaliasbyname">getaliasbyname</A></B>(3)
and display the result.
<DT id="6"><B>ethers</B>
<DD>
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
in succession to
<B><A HREF="/cgi-bin/man/man2html?3+ether_aton">ether_aton</A></B>(3)
and
<B><A HREF="/cgi-bin/man/man2html?3+ether_hostton">ether_hostton</A></B>(3)
until a result is obtained, and display the result.
Enumeration is not supported on
<B>ethers</B>,
so a
<I>key</I>
must be provided.
<DT id="7"><B>group</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setgrent">setgrent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getgrent">getgrent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endgrent">endgrent</A></B>(3)
to enumerate the group database.
When one or more
<I>key</I>
arguments are provided, pass each numeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getgrgid">getgrgid</A></B>(3)
and each nonnumeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getgrnam">getgrnam</A></B>(3)
and display the result.
<DT id="8"><B>gshadow</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setsgent">setsgent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getsgent">getsgent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endsgent">endsgent</A></B>(3)
to enumerate the gshadow database.
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
in succession to
<B><A HREF="/cgi-bin/man/man2html?3+getsgnam">getsgnam</A></B>(3)
and display the result.
<DT id="9"><B>hosts</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+sethostent">sethostent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+gethostent">gethostent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endhostent">endhostent</A></B>(3)
to enumerate the hosts database.
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+gethostbyaddr">gethostbyaddr</A></B>(3)
or
<B><A HREF="/cgi-bin/man/man2html?3+gethostbyname2">gethostbyname2</A></B>(3),
depending on whether a call to
<B><A HREF="/cgi-bin/man/man2html?3+inet_pton">inet_pton</A></B>(3)
indicates that the
<I>key</I>
is an IPv6 or IPv4 address or not, and display the result.
<DT id="10"><B>initgroups</B>
<DD>
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
in succession to
<B><A HREF="/cgi-bin/man/man2html?3+getgrouplist">getgrouplist</A></B>(3)
and display the result.
Enumeration is not supported on
<B>initgroups</B>,
so a
<I>key</I>
must be provided.
<DT id="11"><B>netgroup</B>
<DD>
When one
<I>key</I>
is provided, pass the
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+setnetgrent">setnetgrent</A></B>(3)
and, using
<B><A HREF="/cgi-bin/man/man2html?3+getnetgrent">getnetgrent</A></B>(3)
display the resulting string triple
(<I>hostname</I>, <I>username</I>, <I>domainname</I>).
Alternatively, three
<I>keys</I>
may be provided, which are interpreted as the
<I>hostname</I>,
<I>username</I>
and
<I>domainname</I>
to match to a netgroup name via
<B><A HREF="/cgi-bin/man/man2html?3+innetgr">innetgr</A></B>(3).
Enumeration is not supported on
<B>netgroup</B>,
so either one or three
<I>keys</I>
must be provided.
<DT id="12"><B>networks</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setnetent">setnetent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getnetent">getnetent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endnetent">endnetent</A></B>(3)
to enumerate the networks database.
When one or more
<I>key</I>
arguments are provided, pass each numeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getnetbyaddr">getnetbyaddr</A></B>(3)
and each nonnumeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getnetbyname">getnetbyname</A></B>(3)
and display the result.
<DT id="13"><B>passwd</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setpwent">setpwent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getpwent">getpwent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endpwent">endpwent</A></B>(3)
to enumerate the passwd database.
When one or more
<I>key</I>
arguments are provided, pass each numeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getpwuid">getpwuid</A></B>(3)
and each nonnumeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getpwnam">getpwnam</A></B>(3)
and display the result.
<DT id="14"><B>protocols</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setprotoent">setprotoent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getprotoent">getprotoent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endprotoent">endprotoent</A></B>(3)
to enumerate the protocols database.
When one or more
<I>key</I>
arguments are provided, pass each numeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getprotobynumber">getprotobynumber</A></B>(3)
and each nonnumeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getprotobyname">getprotobyname</A></B>(3)
and display the result.
<DT id="15"><B>rpc</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setrpcent">setrpcent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getrpcent">getrpcent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endrpcent">endrpcent</A></B>(3)
to enumerate the rpc database.
When one or more
<I>key</I>
arguments are provided, pass each numeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getrpcbynumber">getrpcbynumber</A></B>(3)
and each nonnumeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getrpcbyname">getrpcbyname</A></B>(3)
and display the result.
<DT id="16"><B>services</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setservent">setservent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getservent">getservent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endservent">endservent</A></B>(3)
to enumerate the services database.
When one or more
<I>key</I>
arguments are provided, pass each numeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getservbynumber">getservbynumber</A></B>(3)
and each nonnumeric
<I>key</I>
to
<B><A HREF="/cgi-bin/man/man2html?3+getservbyname">getservbyname</A></B>(3)
and display the result.
<DT id="17"><B>shadow</B>
<DD>
When no
<I>key</I>
is provided, use
<B><A HREF="/cgi-bin/man/man2html?3+setspent">setspent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getspent">getspent</A></B>(3),
and
<B><A HREF="/cgi-bin/man/man2html?3+endspent">endspent</A></B>(3)
to enumerate the shadow database.
When one or more
<I>key</I>
arguments are provided, pass each
<I>key</I>
in succession to
<B><A HREF="/cgi-bin/man/man2html?3+getspnam">getspnam</A></B>(3)
and display the result.
</DL>
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<DL COMPACT>
<DT id="18"><B>-s&nbsp;</B><I>service</I>, <B>--service&nbsp;</B><I>service</I>
<DD>
Override all databases with the specified service.
(Since glibc 2.2.5.)
<DT id="19"><B>-s&nbsp;</B><I>database</I>:<I>service</I>, --service&nbsp;<I>database</I>:<I>service</I>
<DD>
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.)
<DT id="20"><B>-i</B>, <B>--no-idn</B>
<DD>
Disables IDN encoding in lookups for
<B>ahosts</B>/<B><A HREF="/cgi-bin/man/man2html?3+getaddrinfo">getaddrinfo</A></B>(3)
(Since glibc-2.13.)
<DT id="21"><B>-?</B>, <B>--help</B>
<DD>
Print a usage summary and exit.
<DT id="22"><B>--usage</B>
<DD>
Print a short usage summary and exit.
<DT id="23"><B>-V</B>, <B>--version</B>
<DD>
Print the version number, license, and disclaimer of warranty for
<B>getent</B>.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>EXIT STATUS</H2>
One of the following exit values can be returned by
<B>getent</B>:
<DL COMPACT><DT id="24"><DD>
<DL COMPACT>
<DT id="25"><B>0</B>
<DD>
Command completed successfully.
<DT id="26"><B>1</B>
<DD>
Missing arguments, or
<I>database</I>
unknown.
<DT id="27"><B>2</B>
<DD>
One or more supplied
<I>key</I>
could not be found in the
<I>database</I>.
<DT id="28"><B>3</B>
<DD>
Enumeration not supported on this
<I>database</I>.
</DL>
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?5+nsswitch.conf">nsswitch.conf</A></B>(5)
<A NAME="lbAH">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="29"><A HREF="#lbAB">NAME</A><DD>
<DT id="30"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="31"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="32"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="33"><A HREF="#lbAF">EXIT STATUS</A><DD>
<DT id="34"><A HREF="#lbAG">SEE ALSO</A><DD>
<DT id="35"><A HREF="#lbAH">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:13 GMT, March 31, 2021
</BODY>
</HTML>