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