The service command is supported on most distributions. The -status-all option will report the current status of all services defined in /etc/init.d. The output format varies between distributions:
$> service -status-all
Debian:
[ + ] acpid [ - ] alsa-utils [ - ] anacron [ + ] atd [ + ] avahi-daemon [ - ] bootlogs [ - ] bootmisc.sh ...
CentOS:
abrt-ccpp hook is installed abrtd (pid 4009) is running... abrt-dump-oops is stopped acpid (pid 3674) is running... atd (pid 4056) is running... auditd (pid 3029) is running... ...
The grep command will reduce the output to only running tasks:
Debian:
$ service -status-all | grep +
CentOS:
$ service -status-all | grep running
You should disable any unnecessary services. This reduces the load on the system and improves the system security.
Services to check for include the following:
- smbd, nmbd: These are the Samba daemons used to share resources between Linux and Windows systems.
- telnet: This is the old, insecure login program. Unless there is an overwhelming need for this, use SSH.
- ftp: This is the old, insecure File Transfer Protocol. Use SSH and scp instead.
- rlogin: This is remote login. SSH is more secure.
- rexec: This is remote exec. SSH is more secure.
- automount: If you are not using NFS or Samba you probably don't need this.
- named: This daemon provides Domain Name Service (DNS). It's only necessary if the system is defining the local names and IP addresses. You don't need it to resolve names and access the net.
- lpd: The Line Printer Daemon lets other systems use this system's printer. If this is not a print server, you don't need this service.
- nfsd: This is the Network File System daemon. It lets remote machines mount this computer's disk partitions. If this is not a file server, you probably don't need this service.
- portmap: This is part of the NFS support. If the system is not using NFS, you don't need this.
- mysql: The mysql application is a database server. It may be used by your webserver.
- httpd: This is the HTTP daemon. It sometimes gets installed as part of a Server System set of packages.
There are several potential ways to disable an unnecessary service depending on whether your system is Redhat or Debian derived, and whether it's running systemd, SysV, or Upstart. All of these commands must be run with root privileges.