I didn’t know there is a /etc/services sitting there, just like I didn’t know ascii(7) before.

It is a plain ASCII files, listing network service’s name, port number, protocol (TCP/UDP), aliases, and comments. The list includes well-known (port number 0 through 1023) IANA’s Service Name and Transport Protocol Port Number Registry, registered ports (1024-49151), as well as dynamic and/or private ports (49152-65535) on my system.

You can simply grep it to query:


% grep '\b80\b' /etc/services
http 80/tcp www www-http # World Wide Web HTTP
http 80/udp www www-http

Before I stumbled on whatportis which taught me about this file, I searched for the port number in search engine whenever I saw some strange incoming transmission on a port number that I didn’t recognize.

According to services(5), C library routines, such as getservbyport(3), use the services list. They parse and utilize the results.

The content of the file varies by distributions and operating systems, but the source probably all is from IANA’s list or just using another distribution as upstream source.