0

I've installed apache2 on a server running Ubuntu 20.04.1 LTS and it's current status is running. Shouldn't I be able to see that service also in the /etc/services file?

1

/etc/services is not a list of services currently running on your computer. It is not even a list of possible services on your or on any particular computer: not all services are listed in /etc/services, and implementations of some of the services listed in it might not even exist in your Linux distribution.

Instead, it is a mapping between port numbers and human-readable port names, for library routines like getservent(3), getservbyport(3) and getservbyport(3). Basically, it's a copy of (some version of) IANA's master list of service names and port numbers, with possibly some distribution-specific additions, using a specific format that's directly usable by those library routines.

For example, if you run netstat -a -A inet, you may see some ports (typically the more well-known ones) identified by name, and the rest by number. If you add the -n option, the port-number-to-name mapping will be omitted and you will see all the port numbers as just numbers.

One of the very few places where it is/was the norm to use port names exclusively is the /etc/inetd.conf file for the classic inetd daemon. In modern software, you are either expected to just use port numbers, or can opt to use either names or numbers as you wish.

1

The service should be under :

/lib/systemd/system/apache2.service

Writing_unit_files

/usr/lib/systemd/system/: units provided by installed packages

/etc/systemd/system/: units installed by the system administrator

systemd.unit manpages

2
  • So not all services are listed in /etc/services? – Themelis Dec 9 '20 at 16:04
  • 1
    Perhaps they're looking for the "http" entry for port 80/tcp in /etc/services? – Jeff Schaller Dec 9 '20 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.