Lynis Explained: How to Audit and Harden Linux Systems

Lynis is a free, open source security auditing tool for Linux, macOS and Unix systems. It runs hundreds of checks on a host, covering boot settings, authentication, file permissions, services, firewall, logging, kernel parameters and installed software, and produces warnings, suggestions and a "hardening index" score.

Jul 19, 2025 - 12:01
Updated: 
105.5k

Linux Administration in IT Infrastructure · Tutorial

Cybersecurity Foundations

Lynis Explained: How to Audit and Harden Linux Systems

Quick answer: Lynis is a free, open source security auditing tool for Linux, macOS and Unix systems. It runs hundreds of checks on a host, covering boot settings, authentication, file permissions, services, firewall, logging, kernel parameters and installed software, and produces warnings, suggestions and a "hardening index" score. Install it from your package manager or GitHub, run sudo lynis audit system, fix the warnings first, then work through suggestions and rescan. It is a quick way to find hardening gaps, but its score is a guide, not proof of compliance with a standard such as the CIS Benchmarks.

Key takeaways

  • Lynis runs locally, needs no agent, and does not change the system.
  • Fix warnings first; suggestions are lower priority improvements.
  • The hardening index helps track progress over time.
  • Use OpenSCAP or CIS-CAT for formal benchmark compliance.
  • Automate regular scans and compare results.

Table of Contents

What Does Lynis Check?

AreaExamples
Boot and kernelBootloader password, sysctl hardening
AuthenticationPassword policies, PAM, sudo configuration
SSHRoot login, password authentication, ciphers
File systemsMount options, world-writable files, SUID binaries
Services and softwareUnnecessary services, outdated packages
Firewall and networkingActive firewall, open ports
Logging and auditingsyslog, auditd
Malware and integrityPresence of tools such as AIDE or rkhunter

How Do You Install Lynis?

# Debian/Ubuntu
sudo apt install lynis

# RHEL/Fedora (EPEL may be needed on RHEL)
sudo dnf install lynis

# Latest version from GitHub (no installation needed)
git clone https://github.com/CISOfy/lynis
cd lynis && sudo ./lynis audit system

Distribution packages can lag behind; the GitHub version has the newest tests.

How Do You Run an Audit?

sudo lynis audit system                 # full local audit
sudo lynis audit system --quick         # no pauses between sections
sudo lynis show details SSH-7408        # explain a specific test

How Do You Read the Results?

  • Warnings: likely security issues; address first.
  • Suggestions: improvements; evaluate each for your environment.
  • Hardening index: a 0 to 100 score summarising results.
  • Files: detailed log in /var/log/lynis.log and machine-readable data in /var/log/lynis-report.dat.
sudo grep -E "^warning|^suggestion" /var/log/lynis-report.dat | head -20
sudo grep hardening_index /var/log/lynis-report.dat

How Do You Fix Common Findings?

FindingFix
SSH allows root login or passwordsSet PermitRootLogin no and PasswordAuthentication no after setting up keys
No firewall activeEnable firewalld, UFW or nftables with default deny
auditd not runningsudo systemctl enable --now auditd
Packages need updatesRun updates and enable automatic security updates
Weak sysctl settingsSet values such as net.ipv4.conf.all.accept_redirects=0 in /etc/sysctl.d/

Re-run Lynis after each round of fixes and record the hardening index.

How Do You Automate Lynis?

# /etc/cron.weekly/lynis (make executable)
#!/bin/sh
/usr/sbin/lynis audit system --cronjob --quiet
cp /var/log/lynis-report.dat /var/log/lynis-report-$(date +%F).dat

Send results to your log platform to track trends across servers.

How Does Lynis Compare with Other Tools?

ToolStrength
LynisFast, broad hardening review with practical suggestions
OpenSCAPFormal compliance profiles (CIS, DISA STIG) and remediation scripts
CIS-CATOfficial scoring against CIS Benchmarks
Vulnerability scannersMissing patches and known CVEs

See NIST SP 800-123 for server security principles and our Linux server hardening guide. WebAsha offers Linux security training.

References

Frequently Asked Questions

A free, open source security auditing tool for Linux, macOS and Unix systems.

No. It only checks and reports; you apply fixes yourself.

Install it and run sudo lynis audit system.

A score from 0 to 100 summarising audit results, useful for tracking progress.

In /var/log/lynis.log and /var/log/lynis-report.dat.

Warnings first, as they indicate likely security issues; then evaluate suggestions.

No. Use OpenSCAP or CIS-CAT for formal benchmark compliance.

Yes. Use the --cronjob option in a scheduled job and collect the report files.

What's Your Reaction?

Like Like 1
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.