Skip to main content
In this guide, we’ll explore best practices for keeping your system lean and secure by eliminating unnecessary packages and services. Over time, systems can accumulate software installed by default from snapshots or image templates, which increases complexity and enlarges your security attack surface.
Regularly auditing installed software and services is vital. This process helps ensure that only essential components are maintained and updated with the latest security patches. For example, verify whether Apache is genuinely needed on Kubernetes cluster nodes or if it was installed inadvertently.
The image advises installing only necessary packages, listing "kubelet," "kubeadm," "Container runtime," and "kubectl" in green, and "apache2" in red.

Managing Services with systemd

Modern Linux distributions commonly use systemd to manage services. The systemctl utility provides comprehensive control to view service status, start, and stop essential services. For instance, to check the status of the Apache service, run:
This output confirms that Apache is active and running, with its main configuration file located at /lib/systemd/system/apache2.service. While many packages install their service files automatically, some services might be manually added to launch additional processes. It is crucial to identify and manage only the services required for your environment.

Listing All Installed Services

To view all services installed on your system, use:
A sample output includes:

Disabling Unnecessary Services

If you determine that a service file is not needed, you can disable and stop it. For example, to disable Apache:
You might see output similar to:
After stopping the service, remove the corresponding package. For example, to remove Apache using apt:
A sample removal process output would be:
Before purging any package, ensure that it is not required by other services or dependencies. Removing essential software may disrupt system functionality.

Further Reading

For additional best practices in configuring and managing services, refer to section 2 of the CIS Benchmarks for Distribution Independent Linux. By following these guidelines, you can streamline your system by maintaining only the essential packages and services, thereby reducing complexity and enhancing overall security.

Watch Video