7

I would like to know the difference between these commands to show linux services:

cat /etc/services

and

service --status-all
Shayan
  • 1,503

1 Answers1

19

The contents of /etc/services do not actually correspond to the services on your system. That file is actually a mapping of ports to the services that usually use them (say, port 22 by SSH). It's used by tools like netstat to give an understandable name in the output (instead of just dumping the port number). So it might, and usually does, have a large number of services listed that are not actually installed on your system.

The output of service --status-all is actually the status of installed services on your system.

See also:

muru
  • 197,895
  • 55
  • 485
  • 740
  • 3
    Would be perfect with references to man pages : http://manpages.ubuntu.com/manpages/xenial/man8/service.8.html and http://manpages.ubuntu.com/manpages/xenial/man5/services.5.html – pim Mar 07 '18 at 16:32