What Is /etc/services in Linux/Unix?

The Linux Services files store well-known ports

UNIX operating systems store what's called a services file at /etc/services. It stores information about numerous services that client applications might use on the computer. Within the file are the service name, port number, and protocol it uses, and any applicable aliases. 

The port numbers are mapped to specific services just like the host's file on Windows computers map a hostname to an IP address. However, the UNIX operating system's services file does not include IP addresses but instead information like whether the service is TCP or UDP and what common names it might go by.

Example of a UNIX Services File

services file

On UNIX, the key role of the configuration file /etc/services is so that programs can do a getportbyname() sockets call in their code in order to understand what port they should use. For example, a POP3 email daemon queries getportbyname (POP3) to retrieve the number 110 that POP3 runs on. 

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. 

It's unreliable to use the services file to discern what port numbers mean. 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 research the ports in a more generic reference.


All services files follow the same syntax of:

name port/protocol aliases comments

However, an alias and comment for each database entry are not necessary, as you can see in this example services file:

$ cat /etc/services
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#ident "@(#)services 1.34 08/11/19 SMI"
# Network services, Internet style
tcpmux 1/tcp
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp
ftp 21/tcp
ssh 22/tcp # Secure Shell
telnet 23/tcp
smtp 25/tcp mail
time 37/tcp timserver
time 37/udp timserver
name 42/udp nameserver
whois 43/tcp nicname # usually to sri-nic
swat 901/tcp # Samba Web Adm.Tool
servicetag 6481/udp
servicetag 6481/tcp
snmpd 161/udp snmp # SMA snmp daemon

  • What is Unix?

    The Unix operating system is a family of operating systems. Android, macOS, and Linux are all Unix variants. Unix builds robust, multi-user environments that are good for desktops and servers.

  • How do I move a file from one directory to another in Unix?

    Use the Unix/Linux mv command via a Terminal window to move files and folders around your computer. Alternatively, your Unix/Linux distribution should come with a file manager. Commonly used file managers include Nautilus, Dolphin, Thunar, PCManFM, and Caja.

  • What is a Unix shell?

    A Unix shell is a Unix system interface that acts as a command-line interpreter. The Unix shell receives your input via the keyboard and then sends those commands and programs to the operating system to execute.

Was this page helpful?