Nmap tool and services running on a Linux system

There are services running on every Linux system.
Some of these services are necessary and perform essential tasks.

However, after installing a Linux system, or at any other time, you should disable unnecessary services that may be listening and have open ports.
You can use the Nmap tool to gather information about open ports and the services running on them.

To install Nmap:

  • on Debian-based systems:
    sudo apt-get install nmap
  • on Red Hat and Fedora compatible systems:
    sudo dnf install nmap .

After installing Nmap, you can check open ports on your computer by running:

sudo nmap localhost

To disable services, you can use the following commands:

sudo systemctl stop service_name
sudo systemctl disable service_name

For example, to disable the SSH service:

sudo systemctl stop sshd
sudo systemctl disable sshd