sodcalculator

10 Tech How-To

Install Use Vulnerability Scanner Linux

Guide 10-60163 · Updated · Step by step

To install and use a vulnerability scanner on Linux, you choose a tool (like OpenVAS, Lynis, or Nmap), install it via your package manager or official repository, then run a scan against a target system or network and review the report. This guide covers the full process for common scanners, including installation commands, basic usage, and how to interpret results.

Why Scan for Vulnerabilities on Linux

Linux servers power a large share of the internet, and while the base OS is often more secure than alternatives, misconfigurations, outdated packages, and exposed services still create risk. A vulnerability scanner automates the search for known weaknesses, missing patches, weak passwords, and unsafe settings. Regular scanning helps you find problems before an attacker does, and it is a core part of any security maintenance routine, whether you manage one home server or a fleet of production machines.

Choosing the Right Scanner

There is no single best scanner; the right choice depends on what you need to check and how much complexity you want. Here are the most common options:

  • Lynis – a security auditing tool for the system itself. It checks configuration files, installed packages, user accounts, and firewall rules, and gives a hardening score. Great for a quick, local assessment.
  • OpenVAS (Greenbone) – a full network vulnerability scanner with a web interface and a large database of known CVEs. It scans other machines on your network for open ports, outdated services, and known exploits.
  • Nmap – primarily a network mapper, but its scripting engine (NSE) includes many vulnerability detection scripts. Lightweight and flexible, good for targeted checks.
  • Nikto – scans web servers for dangerous files, outdated software, and misconfigurations. Useful if you run websites.

For a single Linux box, start with Lynis. For scanning multiple machines, OpenVAS is more comprehensive. If you just need to check a specific service, Nmap scripts might be enough.

Installing a Vulnerability Scanner

Installation methods vary by tool and distribution. Always use your package manager or the official repository to avoid untrusted binaries.

Install Lynis

Lynis is in most default repositories. On Debian/Ubuntu:

sudo apt update
sudo apt install lynis

On RHEL/CentOS/Fedora:

sudo dnf install lynis

If your distribution’s version is old, you can add the official CISOfy repository for the latest release.

Install OpenVAS (Greenbone)

OpenVAS is heavier and requires a service setup. On Debian/Ubuntu:

sudo apt update
sudo apt install gvm
sudo gvm-setup
sudo gvm-start

The setup initializes the database and downloads vulnerability feeds, which can take several minutes. After starting, access the web interface at https://localhost:9392 with the admin credentials generated during setup.

Install Nmap

sudo apt install nmap

Or on Fedora: sudo dnf install nmap

Running Your First Scan

Once installed, run a scan appropriate to your goal.

Lynis system audit

Run as root (or with sudo) for full visibility:

sudo lynis audit system

Lynis prints a report to the terminal and saves a log file. At the end, it gives a hardening index and suggests specific actions, like “Install a PAM module for password strength” or “Set a timeout on idle sessions.”

OpenVAS network scan

In the Greenbone web interface, you create a new task, define a target (IP or hostname), and choose a scan config (like “Full and fast”). The scan runs in the background and produces a report with a severity rating for each finding, from low to critical.

Nmap vulnerability script

To check a single host for known vulnerabilities in its services, use:

nmap --script vuln <target-ip>

This runs a set of scripts that test for common issues, like the Heartbleed bug or open SMB shares.

Interpreting the Results

A scan report is only useful if you understand what it means. Most tools rate findings by severity (low, medium, high, critical) and provide a description and a reference to a CVE (Common Vulnerabilities and Exposures) identifier. You should:

  • Prioritize critical and high findings first – these are the easiest to exploit and cause the most damage.
  • Verify that the finding is real – false positives happen, especially with network scanners. Confirm by checking the service version or configuration manually.
  • Check if the issue applies to your setup – a scanner might flag a service that is only bound to localhost, which is less risky.
  • Look for missing patches – most critical findings are fixed by updating the package. Run sudo apt update && sudo apt upgrade (or your distribution’s equivalent) regularly.

For Lynis, the hardening index is a score from 0 to 100 that reflects how many hardening measures are in place. A score above 70 is decent, but the individual suggestions matter more than the number.

Common Problems and Mistakes

New users often run into the same issues:

  • Not running as root – Lynis and some Nmap scripts need elevated privileges to read all system files. Without sudo, you get incomplete results.
  • Scanning without permission – Scanning systems you do not own or have explicit permission to test is illegal in many jurisdictions. Always scan only your own machines or those you are authorized to test.
  • Ignoring the update step – Vulnerability databases change daily. If you do not update the scanner’s feed (e.g., sudo gvm-feed-update for OpenVAS), you will miss recent CVEs.
  • Misreading severity – A “high” severity does not always mean immediate danger. Consider the context: a high-severity issue in a service that is not exposed to the internet is less urgent than a medium issue in a public-facing service.
  • Not fixing the root cause – Patching the package is good, but if the vulnerability was caused by a misconfiguration, you need to change the configuration to prevent recurrence.

Safety and Legal Considerations

Vulnerability scanning is a double-edged sword. Running a scanner against a machine you do not control can be considered an attack. Even on your own network, be careful: some scans can crash services or trigger intrusion detection alarms. Always:

  • Get written permission before scanning any third-party system.
  • Run scans during maintenance windows if you are testing production systems.
  • Use the least aggressive scan type that answers your question (e.g., a simple port scan before a full vulnerability scan).
  • Keep the scanner itself updated and secure – a compromised scanner is a serious risk.

If you are new to security testing, start on an isolated test machine or a virtual machine. That way you learn the tool without risking your main system.

Alternatives and Complementary Tools

OpenVAS and Lynis are not the only options. Other tools you might consider:

  • ClamAV – for malware scanning on Linux servers (not a vulnerability scanner per se, but often used alongside).
  • chkrootkit or rkhunter – detect rootkits and backdoors.
  • Wazuh – a full SIEM that includes vulnerability detection, but is more complex to set up.
  • Trivy – scans container images and filesystems for known vulnerabilities, ideal if you use Docker.

No single tool covers everything. A good practice is to combine a system auditor (Lynis) with a network scanner (OpenVAS) and a web scanner (Nikto) if you host websites.

Frequently Asked Questions

Do I need to be root to run a vulnerability scan?

Most scanners work better with root privileges. Lynis explicitly requires root to audit all system files. Nmap can run as a normal user for basic port scans, but many vulnerability scripts need root to read service versions. OpenVAS runs as a service and handles privileges itself.

Can vulnerability scanning break my system?

It is rare but possible. Some aggressive scans can cause services to crash or consume high CPU. Scanning a production system during peak hours is not recommended. Always start with a gentle scan and increase intensity gradually.

How often should I run a vulnerability scan?

For a personal server, monthly is reasonable. For production systems, weekly or after any major change (new software, configuration updates) is advisable. The key is to also update the scanner’s vulnerability database before each scan.

What is the difference between a vulnerability scanner and an antivirus?

An antivirus looks for known malware signatures on the system. A vulnerability scanner looks for weaknesses that could allow an attacker to install malware in the first place. They complement each other.

Is OpenVAS free to use?

Yes, OpenVAS (now part of Greenbone) is open source and free. The community edition includes a comprehensive vulnerability feed, though some advanced enterprise features are paid.

Why does my scan show false positives?

Scanners rely on version numbers and configuration patterns, which can be misleading. For example, a service might be patched but still report an old version number. Always verify critical findings manually before taking action.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →