This file is mostly just a copy of /etc/services
from an old version of BSD – since Windows uses the same "BSD sockets" API and even brought in various client programs (ftp, telnet, rsh, finger commands) from it, it needs an services
file in order for the getservbyname()
function to work.
On Unix, various Internet servers and clients used to call getservbyname()
to find out what port they should listen to; getservbyname("finger", "tcp")
would return port 79. But when /etc/hosts
was replaced by DNS, /etc/services
was not – so it would quickly get out of date as the number of sites grew.
I'm guessing it's because of this that programs stopped using getservbyname()
and started using their own config files, or hardcoded port numbers, instead. I think only the inetd daemon (and its xinetd successor) still uses service names as part of its configuration. And only legacy clients like telnet or ftp use the service names to connect.
These days, the file is mostly informational – for example, the netstat
program can translate ports to service names, just like it translates IP addresses to hostnames.
$ netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:pulse-native *:* LISTEN
tcp6 0 0 [::]:mpd [::]:* LISTEN
tcp6 0 0 [::]:pulse-native [::]:* LISTEN
tcp6 0 0 [::]:netbios-ssn [::]:* LISTEN
tcp6 0 0 [::]:finger [::]:* LISTEN
tcp6 0 0 [::]:auth [::]:* LISTEN
On Windows, I'm sure, the file is used even less – I can't remember any program that uses it, other than the same ftp and telnet tools.
SAP NetWeaver RFC C++ SDK uses services file for reading its spagw ports associated to SAP instances. – thersch – 2018-04-30T07:16:22.833