Network Services Internet Style
The image above examines some well-known port numbers and /etc/services.
Comment lines
Service name
Port number/protocol
Aliases
This line indicates that the telnet service uses TCP port 23.
The domain service uses both TCP port 53 and UDP port 53. These are different ports.
/etc/services: On UNIX, the configuration file /etc/services maps port numbers to named services.
Purpose of etc/services
Key point: The purpose of etc/services is so that programs can do a getportbyname() sockets call in their code in order to get the port they should use.
For example, a POP3 email daemon would do a getportbyname ("pop3") in order to retrieve the number 110 that pop3 runs at.
The idea is that if all POP3 daemons use getportbyname(), then no matter what POP3 daemon you run, you can always reconfigure its port number by editing / etc/services.
MisInterpretation:
If you want to find out what ports programs are using, you should instead use the program lsof to find out exactly which ports are bound to which processes.
If running lsof is not appropriate, then you should lookup the ports in a more generic reference.