• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Linux

Understanding /etc/services file in Linux

Published: January 9, 2019 | Modified: June 24, 2020



The article helps you to understand /etc/services file in Linux. Learn about content, format & importance of this file.

/etc/services file in Linux

Internet daemon is an important service in the Linux world. It takes care of all network services with the help of /etc/services file. In this article, we will walk you through the content, format of this file, and what it means to a Linux system.

/etc/services file contains a list of network services and ports mapped to them. inetd or xinetd looks at these details so that it can call a particular program when a packet hits respective port and demand for service.

As a normal user, you can view this file since the file is world-readable. To edit this file you need to have root privileges.

$ ll /etc/services
-rw-r--r--. 1 root root 670293 Jun  7  2013 /etc/services

/etc/services file format

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

Last two fields are optional hence denoted in [ ] where –

  • service-name is the name of the network service. e.g. telnet, FTP, etc.
  • port/protocol is the port being used by that network service (numerical value) and protocol (TCP/UDP) used for communication by service.
  • alias is an alternate name for service.
  • a comment is a note or description you can add to service. Starts with # mark

Sample /etc/services file

# Each line describes one service, and is of the form:
#
# service-name  port/protocol  [aliases ...]   [# comment]

tcpmux          1/tcp                           # TCP port service multiplexer
rje             5/tcp                           # Remote Job Entry
echo            7/udp
discard         9/udp           sink null

Here, you can see the use of optional last two fields as well. discard service has an alternate name as sink or null.

⇠ Previous article
Install LAMP in RHEL
Next article ⇢
How to start, stop & restart MariaDB server in Linux

Related stuff:

  • sar command (Part II) : CPU, Memory reporting
  • cut command and its examples
  • NFS configuration in Linux and HPUX
  • How to zip, unzip files and directories in Linux / Unix
  • Recover forgotten root password in RHEL with screenshots
  • How to configure NTP client in Linux
  • Difference between LVM and LVM2: Linux interview question explained
  • Understanding /etc/hosts file
  • Why ps output shows UID instead of username
  • How to disable IPv6 on Linux
  • 4 ways to check the size of physical memory (RAM) in Linux
  • SUSE Manager Server 4 installation with screenshots

Filed Under: Linux Tagged With: /etc/service syntax, /etc/services file format, where to define service port in linux

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.