The Services File


Another system file you just can't live without...

The services file is another one of those UNIX/Linux system data files that you may need to tweak from time-to-time if you are interested in maintaining a network. Even if you are not that interested in networking, the services file can show you what ports are currently associated with what services on your machine. This in turn may help you to identify what sockets are being used since a socket is composed of a hostname and a port number.

The services file is closely tied to the inetd.conf file too. You can think of them as companion pieces. A service that is called by port will often cross-reference the inetd.conf file to retrieve the actual program name. The opposite order may also be in effect. Names are fine for human users, but the machines eventually prefer numbers. (A parallel lays in a DNS's receiving a name and returning a number associated with that domain name.)

Here you will also find all the "well-known" port numbers for the standard services found on the internet, such as: telnet and 23, or http and 80, or chat and 87, etc. These numbers have been assigned by the IANA, having remained a convention for the past 25 years or so, and probably continuing as such well into the future...

Although on some platforms it is strongly suggested that no edits be made to this file, there is no reason why you can't add services of your own as long as you are mindfull of possible modifications due the inetd.conf file, even though not all ports have software counterparts in the inetd.conf. (And, be sure to choose new port numbers for your own services that are greater than 1024, the current upper bound for the well-known internet ports.)




My Sample Services File

Here is what my services file looks like on ka1fsb-10.ampr.org running an older version of Slackware. As you can see, compared to more recent versions, the number of ports is quite sparse. But, the advantage is the ease with which you may add your own services. For example, AX25 Utilities enthusiasts will see a block of ports from 2001 to 2003 here. These were added after the installation of this software package, as well as having touched the corresponding services in the inetd.conf file.

So the quest usually begins in the services file for the port number. Then it reads the name of the service, such as "node," and then it looks that up in the inetd.conf file to find the path to the binary software. Then it executes the code associated with that service, like the node or telnet or ftp, etc. (However, as noted above, some programs may begin their search in the inetd.conf file and then lookup that service to get a port number from the services file...)

On my SuSE machine, a much more populated machine then the desktop, there are almost no free ports available. So, I really had to struggle to find enough ports to add any new installs of my own. But, they are there, you just have to look for them. (Many services are listed and preceded by the "#" which marks them as a comment and effectively disables them. Those port numbers are therefore useable by you for some other service as long as you remember that you "stole" and re-cycled them.)

You also may use telnet to explore some of the services in the services file. Not all will respond to telnet, but many will. For example, you may telnet port 11 to see a listing similar to the netstat command:

  • telnet localhost 11


... the list will fly by quickly. If there is too much data, you can dump the output into a regular file and then use "less" or "more" to review the data in detail. Because we are working with sockets here, we can't use the usual file system "helpers" like the "pipe" or the redirect symbol ">" into a file. But once the listing is lodged in the file system, we can!

A quick note on the file data structure: Column one lists the "offical" name of the service, column two shows the port numbers for both tcp and udp, the next column is optional and may contain the alias name for the service, such as http for www. The last column, also an option, may list a description or comment in this field.

You can learn alot from just taking a casual tour of your services file! It can tell you what is running, or could potentialy be running, on your machine. It can show you the number of ports being used and possibly the level of vulnerability of your system. (Too many ports without adequate protection can make for a bad network day.) But otherwise, it is a good place to begin to get to know your Linux or UNIX system package and the resources it has to offer...

The /etc/services File on ka1fsb-10.ampr.org

Name | Ports | Alias | Description
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1340, ``Assigned Numbers'' (July 1992).  Not all ports
# are included, only the more common ones.
#
#	from: @(#)services	5.8 (Berkeley) 5/9/91
#	$Id: services,v 1.9 1993/11/08 19:49:15 cgd Exp $
#
tcpmux		1/tcp		# TCP port service multiplexer
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
qotd		17/tcp		quote
msp		18/tcp		# message send protocol
msp		18/udp		# message send protocol
chargen		19/tcp		ttytst source
chargen		19/udp		ttytst source
ftp		21/tcp
# 22 - unassigned
telnet		23/tcp
# 24 - private
smtp		25/tcp		mail
# 26 - unassigned
time		37/tcp		timserver
time		37/udp		timserver
rlp		39/udp		resource	# resource location
nameserver	42/tcp		name		# IEN 116
whois		43/tcp		nicname
domain		53/tcp		nameserver	# name-domain server
domain		53/udp		nameserver
mtp		57/tcp				# deprecated
bootps		67/tcp		# BOOTP server
bootps		67/udp
bootpc		68/tcp		# BOOTP client
bootpc		68/udp
tftp		69/udp
gopher		70/tcp		# Internet Gopher
gopher		70/udp
rje		77/tcp		netrjs
finger		79/tcp
www		80/tcp		http	# WorldWideWeb HTTP
www		80/udp			# HyperText Transfer Protocol
link		87/tcp		ttylink
link		87/udp		ttylink
kerberos	88/tcp		krb5	# Kerberos v5
kerberos	88/udp
supdup		95/tcp
# 100 - reserved
hostnames	101/tcp		hostname	# usually from sri-nic
iso-tsap	102/tcp		tsap		# part of ISODE.
csnet-ns	105/tcp		cso-ns	# also used by CSO name server
csnet-ns	105/udp		cso-ns
rtelnet		107/tcp		# Remote Telnet
rtelnet		107/udp
pop2		109/tcp		postoffice	# POP version 2
pop2		109/udp
pop3		110/tcp		# POP version 3
pop3		110/udp
sunrpc		111/tcp
sunrpc		111/udp
auth		113/tcp		tap ident authentication
sftp		115/tcp
uucp-path	117/tcp
nntp		119/tcp		readnews untp	# USENET News Transfer Protocol
ntp		123/tcp
ntp		123/udp				# Network Time Protocol
netbios-ns	137/tcp				# NETBIOS Name Service
netbios-ns	137/udp
netbios-dgm	138/tcp				# NETBIOS Datagram Service
netbios-dgm	138/udp
netbios-ssn	139/tcp				# NETBIOS session service
netbios-ssn	139/udp
imap2		143/tcp				# Interim Mail Access Proto v2
imap2		143/udp
snmp		161/udp				# Simple Net Mgmt Proto
snmp-trap	162/udp		snmptrap	# Traps for SNMP
cmip-man	163/tcp				# ISO mgmt over IP (CMOT)
cmip-man	163/udp
cmip-agent	164/tcp
cmip-agent	164/udp
xdmcp		177/tcp				# X Display Mgr. Control Proto
xdmcp		177/udp
nextstep	178/tcp		NeXTStep NextStep	# NeXTStep window
nextstep	178/udp		NeXTStep NextStep	# server
bgp		179/tcp				# Border Gateway Proto.
bgp		179/udp
prospero	191/tcp				# Cliff Neuman's Prospero
prospero	191/udp
irc		194/tcp				# Internet Relay Chat
irc		194/udp
smux		199/tcp				# SNMP Unix Multiplexer
smux		199/udp
at-rtmp		201/tcp				# AppleTalk routing
at-rtmp		201/udp
at-nbp		202/tcp				# AppleTalk name binding
at-nbp		202/udp
at-echo		204/tcp				# AppleTalk echo
at-echo		204/udp
at-zis		206/tcp				# AppleTalk zone information
at-zis		206/udp
z3950		210/tcp		wais		# NISO Z39.50 database
z3950		210/udp		wais
ipx		213/tcp				# IPX
ipx		213/udp
imap3		220/tcp				# Interactive Mail Access
imap3		220/udp				# Protocol v3
ulistserv	372/tcp				# UNIX Listserv
ulistserv	372/udp
#
# UNIX specific services
#
exec		512/tcp
biff		512/udp		comsat
login		513/tcp
who		513/udp		whod
shell		514/tcp		cmd		# no passwords used
syslog		514/udp
printer		515/tcp		spooler		# line printer spooler
talk		517/udp
ntalk		518/udp
route		520/udp		router routed	# RIP
timed		525/udp		timeserver
tempo		526/tcp		newdate
courier		530/tcp		rpc
conference	531/tcp		chat
netnews		532/tcp		readnews
netwall		533/udp				# -for emergency broadcasts
uucp		540/tcp		uucpd		# uucp daemon
remotefs	556/tcp		rfs_server rfs	# Brunhoff remote filesystem
klogin		543/tcp				# Kerberized `rlogin' (v5)
kshell		544/tcp				# Kerberized `rsh' (v5)
kerberos-adm	749/tcp				# Kerberos `kadmin' (v5)
#
webster		765/tcp				# Network dictionary
webster		765/udp
#
# From ``Assigned Numbers'':
#
#> The Registered Ports are not controlled by the IANA and on most systems
#> can be used by ordinary user processes or programs executed by ordinary
#> users.
#
#> Ports are used in the TCP [45,106] to name the ends of logical
#> connections which carry long term conversations.  For the purpose of
#> providing services to unknown callers, a service contact port is
#> defined.  This list specifies the port used by the server process as its
#> contact port.  While the IANA can not control uses of these ports it
#> does register or list uses of these ports as a convienence to the
#> community.
#
msql		1112/tcp		# msql database
#
ingreslock	1524/tcp
ingreslock	1524/udp
prospero-np	1525/tcp		# Prospero non-privileged
prospero-np	1525/udp
#
#
node		2001/tcp		# LinuxNode
listen		2002/tcp		# Listener
fsbbs		2003/tcp		# FSBBS system
#
rfe		5002/tcp		# Radio Free Ethernet
rfe		5002/udp		# Actually uses UDP only
#
#
# Kerberos (Project Athena/MIT) services
# Note that these are for Kerberos v4, and are unofficial.  Sites running
# v4 should uncomment these and comment out the v5 entries above.
#
#kerberos	750/udp		kdc	# Kerberos (server) udp
#kerberos	750/tcp		kdc	# Kerberos (server) tcp
krbupdate	760/tcp		kreg	# Kerberos registration
kpasswd		761/tcp		kpwd	# Kerberos "passwd"
#klogin		543/tcp			# Kerberos rlogin
eklogin		2105/tcp		# Kerberos encrypted rlogin
#kshell		544/tcp		krcmd	# Kerberos remote shell
#
# Unofficial but necessary (for NetBSD) services
#
supfilesrv	871/tcp			# SUP server
supfiledbg	1127/tcp		# SUP debugging


(Courtesy KBNorton Computer Services)