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 the TCP protocol on your computer by running:

sudo nmap localhost

Please note that services operating on the UDP protocol can be displayed using the command:

sudo nmap -sU 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:

in Debian based systems:

sudo systemctl stop ssh
sudo systemctl disable ssh

or In RPM based systems:

sudo systemctl stop sshd
sudo systemctl disable sshd