Computer Science


SERVICES(5)         Linux Programmer's Manual         SERVICES(5)

NAME
       services - Internet network services list

DESCRIPTION
       services is a plain ASCII file providing a mapping between
       friendly textual names for internet  services,  and  their
       underlying assigned port numbers and protocol types. Every
       networking program should look into this file to  get  the
       port number (and protocol) for its service.  The C library
       routines   getservent(3),   getservbyname(3),   getservby-
       port(3), setservent(3), and endservent(3) support querying
       this file from programs.

       Port numbers are assigned by the IANA  (Internet  Assigned
       Numbers  Authority), and their current policy is to assign
       both TCP and UDP protocols when assigning a  port  number.
       Therefore,  most  entries  will have two entries, even for
       TCP only services.

       Port numbers below 1024 (so-called 'low  numbered'  ports)
       can  only  be  bound  to by root (see bind(2), tcp(7), and
       udp(7).)  This is so that clients connecting to  low  num-
       bered ports can trust that the service running on the port
       is the standard implementation, and not  a  rogue  service
       run  by  a  user  of the machine.  Well-known port numbers
       specified by the IANA are normally located  in  this  root
       only space.

       The  presence  of  an  entry for a service in the services
       file does not necessarily mean that the  service  is  cur-
       rently  running  on the machine. See inetd(5) for the
       configuration of Internet services offered. Note that  not
       all  networking  services  are started by inetd(8), and so
       won't appear in inetd(5).  In particular, news (NNTP)
       and  mail  (SMTP)  servers  are often initialised from the
       system boot scripts.

       The location of the services file is defined by _PATH_SER-
       VICES  in  /usr/include/netdb.h.   This  is usually set to
       /etc/services.

       Each line describes one service, and is of the form:

              service-name   port/protocol   [aliases ...]

       where:

       service-name
                 is the friendly name the service is known by and
                 looked  up  under.  It is case sensitive. Often,
                 the client program is named after  the  service-
                 name.

       port      is  the port number (in decimal) to use for this
                 service.

       protocol  is the type of protocol to be used.  This  field
                 should  match an entry in the protocols(5) file.
                 Typical values include tcp and udp.

       aliases   is an optional space or tab  separated  list  of
                 other  names  for this service (but see the BUGS
                 section below). Again, the names are case sensi-
                 tive.

       Either  spaces or tabs may be used to separate the fields.

       Comments are started by the hash  sign  (#)  and  continue
       until the end of the line. Blank lines are skipped.

       The  service-name  should begin in the first column of the
       file, since leading spaces  are  not  stripped.   service-
       names  can be any printable characters excluding space and
       tab, however, a conservative choice of  characters  should
       be  used  to minimise inter-operability problems. Eg: a-z,
       0-9, and hyphen (-) would seem a sensible choice.

       Lines not matching this format should not  be  present  in
       the file. (Currently, they are silently skipped by getser-
       vent(3), getservbyname(3), and getservbyport(3).  However,
       this behaviour should not be relied on.)

       As  a  backwards  compatibility  feature,  the  slash  (/)
       between the port number and protocol name can in  fact  be
       either  a slash or a comma (,). Use of the comma in modern
       installations is depreciated.

       This file might be distributed over a network using a net-
       work-wide   naming   service   like  Yellow  Pages/NIS  or
       BIND/Hesiod.

       A sample services file might look like this:

              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

BUGS
       There is a maximum of 35 aliases, due to the way the  get-
       servent(3) code is written.

       Lines  longer than BUFSIZ (currently 1024) characters will
       be ignored by getservent(3),  getservbyname(3),  and  get-
       servbyport(3).   However,  this  will  also cause the next
       line to be mis-parsed.

FILES
       /etc/services
              The Internet network services list

       /usr/include/netdb.h
              Definition of _PATH_SERVICES

SEE ALSO
       getservent(3), getservbyname(3), getservbyport(3), setser-
       vent(3),     endservent(3),    protocols(5),    listen(2),
       inetd(5), inetd(8).

       Assigned  Numbers  RFC,  most  recently  RFC  1700,   (AKA
       STD0002)

       Guide to Yellow Pages Service

       Guide to BIND/Hesiod Service

Linux                      11 Jan 1996                          1

Back to the index


Apply now!


Handbook

Postgraduate study options

Computer Science Blog



Please give us your feedback or ask us a question

This message is...


My feedback or question is...


My email address is...

(Only if you need a reply)

A to Z Directory | Site map | Accessibility | Copyright | Privacy | Disclaimer | Feedback on this page