| 1 |
.\" Copyright 1996, Austin Donnelly <[email protected]> |
| 2 |
.\" Copyright 1995, Martin Schulze <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH services 5 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
services \- Internet network services list |
| 10 |
.SH DESCRIPTION |
| 11 |
.B services |
| 12 |
is a plain ASCII file providing a mapping between human-friendly textual |
| 13 |
names for internet services, and their underlying assigned port |
| 14 |
numbers and protocol types. |
| 15 |
Every networking program should look into |
| 16 |
this file to get the port number (and protocol) for its service. |
| 17 |
The C library routines |
| 18 |
.BR getservent (3), |
| 19 |
.BR getservbyname (3), |
| 20 |
.BR getservbyport (3), |
| 21 |
.BR setservent (3), |
| 22 |
and |
| 23 |
.BR endservent (3) |
| 24 |
support querying this file from programs. |
| 25 |
.P |
| 26 |
Port numbers are assigned by the IANA (Internet Assigned Numbers |
| 27 |
Authority), and their current policy is to assign both TCP and UDP |
| 28 |
protocols when assigning a port number. |
| 29 |
Therefore, most entries will |
| 30 |
have two entries, even for TCP-only services. |
| 31 |
.P |
| 32 |
Port numbers below 1024 (so-called "low numbered" ports) can be |
| 33 |
bound to only by root (see |
| 34 |
.BR bind (2), |
| 35 |
.BR tcp (7), |
| 36 |
and |
| 37 |
.BR udp (7)). |
| 38 |
This is so clients connecting to low numbered ports can trust |
| 39 |
that the service running on the port is the standard implementation, |
| 40 |
and not a rogue service run by a user of the machine. |
| 41 |
Well-known port numbers specified by the IANA are normally |
| 42 |
located in this root-only space. |
| 43 |
.P |
| 44 |
The presence of an entry for a service in the |
| 45 |
.B services |
| 46 |
file does not necessarily mean that the service is currently running |
| 47 |
on the machine. |
| 48 |
See |
| 49 |
.BR inetd.conf (5) |
| 50 |
for the configuration of Internet services offered. |
| 51 |
Note that not all |
| 52 |
networking services are started by |
| 53 |
.BR inetd (8), |
| 54 |
and so won't appear in |
| 55 |
.BR inetd.conf (5). |
| 56 |
In particular, news (NNTP) and mail (SMTP) servers are often |
| 57 |
initialized from the system boot scripts. |
| 58 |
.P |
| 59 |
The location of the |
| 60 |
.B services |
| 61 |
file is defined by |
| 62 |
.B _PATH_SERVICES |
| 63 |
in |
| 64 |
.IR <netdb.h> "." |
| 65 |
This is usually set to |
| 66 |
.IR /etc/services "." |
| 67 |
.P |
| 68 |
Each line describes one service, and is of the form: |
| 69 |
.IP |
| 70 |
\f2service-name\ \ \ port\f3/\f2protocol\ \ \ \f1[\f2aliases ...\f1] |
| 71 |
.TP |
| 72 |
where: |
| 73 |
.TP |
| 74 |
.I service-name |
| 75 |
is the friendly name the service is known by and looked up under. |
| 76 |
It is case sensitive. |
| 77 |
Often, the client program is named after the |
| 78 |
.IR service-name "." |
| 79 |
.TP |
| 80 |
.I port |
| 81 |
is the port number (in decimal) to use for this service. |
| 82 |
.TP |
| 83 |
.I protocol |
| 84 |
is the type of protocol to be used. |
| 85 |
This field should match an entry |
| 86 |
in the |
| 87 |
.BR protocols (5) |
| 88 |
file. |
| 89 |
Typical values include |
| 90 |
.B tcp |
| 91 |
and |
| 92 |
.BR udp . |
| 93 |
.TP |
| 94 |
.I aliases |
| 95 |
is an optional space or tab separated list of other names for this |
| 96 |
service. |
| 97 |
Again, the names are case |
| 98 |
sensitive. |
| 99 |
.P |
| 100 |
Either spaces or tabs may be used to separate the fields. |
| 101 |
.P |
| 102 |
Comments are started by the hash sign (#) and continue until the end |
| 103 |
of the line. |
| 104 |
Blank lines are skipped. |
| 105 |
.P |
| 106 |
The |
| 107 |
.I service-name |
| 108 |
should begin in the first column of the file, since leading spaces are |
| 109 |
not stripped. |
| 110 |
.I service-names |
| 111 |
can be any printable characters excluding space and tab. |
| 112 |
However, a conservative choice of characters should be used to minimize |
| 113 |
compatibility problems. |
| 114 |
For example, a\-z, 0\-9, and hyphen (\-) would seem a |
| 115 |
sensible choice. |
| 116 |
.P |
| 117 |
Lines not matching this format should not be present in the |
| 118 |
file. |
| 119 |
(Currently, they are silently skipped by |
| 120 |
.BR getservent (3), |
| 121 |
.BR getservbyname (3), |
| 122 |
and |
| 123 |
.BR getservbyport (3). |
| 124 |
However, this behavior should not be relied on.) |
| 125 |
.P |
| 126 |
.\" The following is not true as at glibc 2.8 (a line with a comma is |
| 127 |
.\" ignored by getservent()); it's not clear if/when it was ever true. |
| 128 |
.\" As a backward compatibility feature, the slash (/) between the |
| 129 |
.\" .I port |
| 130 |
.\" number and |
| 131 |
.\" .I protocol |
| 132 |
.\" name can in fact be either a slash or a comma (,). |
| 133 |
.\" Use of the comma in |
| 134 |
.\" modern installations is deprecated. |
| 135 |
.\" |
| 136 |
This file might be distributed over a network using a network-wide |
| 137 |
naming service like Yellow Pages/NIS or BIND/Hesiod. |
| 138 |
.P |
| 139 |
A sample |
| 140 |
.B services |
| 141 |
file might look like this: |
| 142 |
.P |
| 143 |
.in +4n |
| 144 |
.EX |
| 145 |
netstat 15/tcp |
| 146 |
qotd 17/tcp quote |
| 147 |
msp 18/tcp # message send protocol |
| 148 |
msp 18/udp # message send protocol |
| 149 |
chargen 19/tcp ttytst source |
| 150 |
chargen 19/udp ttytst source |
| 151 |
ftp 21/tcp |
| 152 |
# 22 \- unassigned |
| 153 |
telnet 23/tcp |
| 154 |
.EE |
| 155 |
.in |
| 156 |
.SH FILES |
| 157 |
.TP |
| 158 |
.I /etc/services |
| 159 |
The Internet network services list |
| 160 |
.TP |
| 161 |
.I <netdb.h> |
| 162 |
Definition of |
| 163 |
.B _PATH_SERVICES |
| 164 |
.\" .SH BUGS |
| 165 |
.\" It's not clear when/if the following was ever true; |
| 166 |
.\" it isn't true for glibc 2.8: |
| 167 |
.\" There is a maximum of 35 aliases, due to the way the |
| 168 |
.\" .BR getservent (3) |
| 169 |
.\" code is written. |
| 170 |
.\" |
| 171 |
.\" It's not clear when/if the following was ever true; |
| 172 |
.\" it isn't true for glibc 2.8: |
| 173 |
.\" Lines longer than |
| 174 |
.\" .B BUFSIZ |
| 175 |
.\" (currently 1024) characters will be ignored by |
| 176 |
.\" .BR getservent (3), |
| 177 |
.\" .BR getservbyname (3), |
| 178 |
.\" and |
| 179 |
.\" .BR getservbyport (3). |
| 180 |
.\" However, this will also cause the next line to be mis-parsed. |
| 181 |
.SH SEE ALSO |
| 182 |
.BR listen (2), |
| 183 |
.BR endservent (3), |
| 184 |
.BR getservbyname (3), |
| 185 |
.BR getservbyport (3), |
| 186 |
.BR getservent (3), |
| 187 |
.BR setservent (3), |
| 188 |
.BR inetd.conf (5), |
| 189 |
.BR protocols (5), |
| 190 |
.BR inetd (8) |
| 191 |
.P |
| 192 |
Assigned Numbers RFC, most recently RFC\ 1700, (AKA STD0002). |