Most Linux estates have a hardening standard on paper and no quick, repeatable way to see how far each host has drifted from it. Lynis is an open source, host-based auditing tool from CISOfy that runs on the system itself, executes several hundred individual tests and returns warnings, suggestions and a hardening index. This guide explains what Lynis checks, how to run it safely, how to read its screen output and its report file field by field, what the hardening index does and does not tell you, and how to automate scans across a fleet. It is written for Linux administrators and security engineers who already own a baseline; for the baseline itself see the Linux Server Hardening Guide.
This is an independent guide from NHI Mgmt Group, based on CISOfy's public Lynis documentation and the project source code as of November 2026. It is not sponsored or reviewed by CISOfy. Product features change, so confirm settings against CISOfy's current documentation.
Key takeaways
- Lynis is an auditor, not a fixer. It reads configuration and system state and tells you what to change; remediation stays with your configuration management, so a scan alone changes nothing on the host.
- Run it as root for a full picture. A privileged
lynis audit systemcovers every applicable test;--pentestruns a non-privileged scan and skips the tests that need root. - The report file is the real output.
/var/log/lynis-report.datholds machine-readablekey=valuelines, including everywarning[]andsuggestion[]with its test ID, which is what you feed into tickets, dashboards and a SIEM. - Treat the hardening index as a trend line. It is the ratio of hardening points earned to points available on that host, not a percentage of how safe the system is, and it only compares fairly between hosts that run the same tests.
- Change behaviour through custom.prf. Leave
default.prfuntouched, record skipped tests and exceptions in a version-controlledcustom.prf, and give every skip a reason and an owner.
What Lynis does
The project README describes Lynis as a security auditing tool for UNIX-based systems that "performs an in-depth security scan and runs on the system itself", with goals of automated security auditing, compliance testing and vulnerability detection. CISOfy lists support for AIX, FreeBSD, HP-UX, Linux, macOS, NetBSD, NixOS, OpenBSD and Solaris, and states that its tests draw on CIS Benchmarks, NIST, NSA, OpenSCAP data and vendor guides. It is written in shell, needs no compilation or agent, and is released under the GPLv3. The scan is modular: Lynis detects which components are present (SSH, a web server, a database, a firewall) and runs only the tests that apply.
Each test has a stable identifier made of a group prefix and a number, such as SSH-7408 or AUTH-9228. Tests are also tagged with a category (security, performance or privacy). The table summarises the main test groups in the open source release, counted from the project's include/tests_* files.
| Group prefix | Area | Example test and what it checks |
|---|---|---|
| AUTH | Authentication, accounts, PAM, sudo | AUTH-9228: password file consistency with pwck |
| SSH | OpenSSH server configuration | SSH-7408: specific sshd options such as root login and log level |
| BOOT | Boot loader, services, UEFI | BOOT-5122: GRUB boot password set |
| KRNL | Kernel version, modules, sysctl | KRNL-6000: sysctl key pairs compared with values in the scan profile |
| PKGS | Package managers, updates, vulnerable packages | PKGS-7392: pending Debian or Ubuntu security updates |
| FILE, HOME | File systems, mount options, permissions | FILE-6310: separate /tmp, /home and /var |
| ACCT, LOGG | Accounting, auditd, syslog and log rotation | ACCT-9628: auditd present; LOGG-2154: syslog configuration |
| FIRE, NETW | Host firewall and network settings | FIRE-4512: empty iptables ruleset |
| MACF | Mandatory access control | MACF-6208: AppArmor enabled |
| FINT, MALW, HRDN | File integrity, malware scanners, compiler exposure | FINT-4350: file integrity tool installed; HRDN-7222: compiler permissions |
| CRYP, TIME | Certificates, encrypted swap, time sync | CRYP-7902: certificate expiry; TIME-3104: NTP daemon or client running |
| INSE, HTTP, DBS, MAIL, NAME | Legacy services, web servers, databases, mail, DNS | INSE tests: insecure services such as inetd entries |
| CONT, USB, SCHD, SHLL | Containers, USB storage, cron and at, shells | USB-1000: USB storage disabled |
Lynis complements rather than replaces a formal benchmark scanner. Use it for fast, broad coverage and trend tracking; use the CIS-CAT or OpenSCAP content for your distribution when an auditor needs control-by-control evidence against a named benchmark. See the CIS Benchmarks Guide.
| Need | Lynis | Benchmark scanner (CIS-CAT, OpenSCAP) |
|---|---|---|
| Quick health check of an unknown host | Strong fit: no install, broad coverage | Slower to set up, profile per distribution |
| Evidence against a named benchmark | Indicative only | Strong fit: rule-level pass or fail per profile |
| Mixed Unix estate (BSD, AIX, macOS) | One tool across platforms | Content varies by platform |
| Trend of hardening over time | Hardening index and finding counts | Compliance percentage per profile |
| Automated remediation | None (advice only) | Some content ships remediation scripts |
Running audits
Install from your distribution, from the CISOfy package repository, or by cloning the GitHub repository; the README notes that some distributions ship older versions and recommends the CISOfy repository or the latest release in that case. Lynis 3.1.7 was released on 25 June 2026, and from 3.1.6 the tool treats a release six months or older as old. Older copies miss newer test logic and end-of-life data, so keep the version current.
- Prepare: if you run from a cloned or extracted copy as root, change ownership to root first (the README suggests
chown -R 0:0), otherwise Lynis warns that it is executing files owned by an unprivileged user. Lynis also needs write access to/tmp. - Run a full audit:
sudo lynis audit system. Add--quick(-Q) to stop the pauses between sections and--auditor "Name"to stamp the report. - Run without root where you must:
lynis audit system --pentestperforms a non-privileged scan. The manual page states that tests requiring root are skipped, and the output lists which were skipped, so do not compare these results with privileged scans. - Scope a run:
--tests "SSH-7408 AUTH-9228"runs named tests,--tests-from-group "ssh authentication"runs groups, and--tests-from-category securitylimits to a category.lynis show groupsandlynis show categorieslist the valid values. - Audit a container build file:
lynis audit dockerfile Dockerfilechecks a Dockerfile rather than a running host. - Investigate a finding:
lynis show details SSH-7408prints what that test logged, andlynis show tests SSH-7408describes the test.
Lynis refuses to run if its binary has the set-user-id bit, and it refuses to write a log or report file that is a symbolic link, to avoid symlink attacks. Running it is low risk on production hosts because it reads state; the main operational cost is a short burst of CPU and disk activity from package and file checks, so schedule fleet scans outside peak hours.
Reading results
Screen output shows each test with a status such as [ OK ], [ FOUND ], [ NOT FOUND ], [ WARNING ] or [ SUGGESTION ], followed by a summary. CISOfy's documentation makes two points worth repeating to every team: warnings "are events which really need an action", while suggestions "could indicate room for improvement" and are usually far more numerous; and an [ OK ] result does not always mean the system is correctly or securely configured. Every warning and suggestion carries a test ID and usually a link to further reading.
Two files hold the detail. When run as root the defaults are /var/log/lynis.log (a verbose log of every test and its reasoning, purged at the start of each scan) and /var/log/lynis-report.dat (the structured report). A non-privileged run writes both to the user's home directory. Copy or rotate them if you want history. The report uses one key=value per line; keys ending in [] repeat. The table lists fields you will use most, taken from the source code.
| Report field | Content | Typical use |
|---|---|---|
warning[] | TEST-ID|message|details|solution| | Raise a ticket or alert per warning |
suggestion[] | Same format as warnings | Hardening backlog, grouped by test ID |
hardening_index | Integer from 0 to 100 | Trend per host and per role |
lynis_version, report_datetime_start, report_datetime_end, auditor | Run metadata | Evidence and freshness checks |
hostname, hostid, hostid2, os_name, os_version, os_kernel_version | Host identity | Join to the asset inventory |
tests_executed, tests_skipped, lynis_tests_done | Coverage of this run | Detect profiles that skip too much |
vulnerable_packages_found, vulnerable_package[], available_update[] | Package findings where a package audit tool exists | Feed vulnerability management |
firewall_active, firewall_installed, framework_selinux, file_integrity_tool[], malware_scanner[] | Presence of key controls | Control coverage dashboards |
real_user[], account_without_password[], locked_account[], network_listen_port[] | Accounts and exposed ports | Access reviews and attack surface |
Read the log alongside the report before you act: searching the log for a test ID shows exactly which file or command produced the result. Triage in this order: warnings, then suggestions in the authentication, SSH, logging and package groups, then the rest. The account and port fields are where an audit turns into an identity task, because service accounts, accounts without passwords and SSH keys need owners. See the Linux PAM Guide and the Linux Logging and auditd for Defenders Guide for the most common follow-up work.
Hardening index
The hardening index is calculated in the source as hardening points earned divided by the maximum points available, multiplied by 100. Individual tests award points through a function that adds a score and a maximum for that item, so a test that finds a control fully in place earns all its points and a partial result earns some. Tests that do not apply to a host add nothing to either side. That design has three consequences.
- Not a safety percentage: the author of Lynis writes that the number "is just an indicator on taken measures" and should not be confused with a percentage of how safe a system is. A host with an exposed, unpatched application can still score well.
- Comparable only like for like: skipping tests in a profile changes both the points and the maximum, so compare hosts only when they share the same profile, role and Lynis version. Record the version with every score.
- Raise it by fixing, not by skipping: the honest way to move the number is to implement the control the test looks for. Skips that exist only to lift the score hide risk.
Use the index for direction (is this role improving release by release?) and for outliers (which web servers sit well below their peers?). Set targets per role rather than one fleet number, because a minimal container host and a general purpose bastion have different test sets.
Profiles and tailoring
Profiles control behaviour. default.prf carries the initial values and its own header says not to edit it; copy only your changes into custom.prf in the same directory, or point to another file with --profile. lynis show profiles shows which profiles were found, and lynis show settings shows the resulting configuration. Lynis checks profile lines strictly to avoid harmful injections.
| Setting | Default in default.prf | When to change it |
|---|---|---|
skip-test=SSH-7408 or skip-test=SSH-7408:permitrootlogin | Commented out | A documented exception for a whole test or one option within it |
machine-role | server | Set workstation or personal for desktops so advice fits the role |
error-on-warnings | no | Set yes in pipelines so any warning returns exit code 78 |
quick | yes | Leave on for unattended runs |
upload | no | Only used with a central Lynis Enterprise or compatible collector |
plugin= lines | Plugins listed, some for Lynis Enterprise only | --no-plugins for minimal runs |
Keep custom.prf in version control with one comment per skip naming the reason, the approver and a review date. Build one profile per role (bastion, web, database, container host) so the hardening index stays comparable within each role.
Automation
Lynis becomes useful at scale when scans run on a schedule and the report lands somewhere people look. A phased rollout keeps noise manageable.
- Pilot: run privileged scans by hand on five to ten representative hosts per role, triage every warning, and write the first
custom.prfper role. - Schedule: use
lynis audit system --cronjob, which turns off colours and pauses for unattended use, from cron or a systemd timer, weekly or after each patch cycle. Copy the report to a timestamped file so the next run does not overwrite history. - Collect centrally: ship
lynis-report.datto your log pipeline or SIEM, parsewarning[],suggestion[]andhardening_index, and join onhostidorhostnameto the asset inventory. Restrict access to these files, because they map accounts, open ports and missing controls. - Gate builds: in image pipelines set
error-on-warnings=yesso a golden image that produces any warning fails with exit code 78 before it is published. - Close the loop: fix findings in your configuration management (Ansible, Puppet, Salt or similar), never by hand on one host, and re-scan to confirm. See the Configuration Drift and Baseline Enforcement Guide.
- Roll back safely: if a remediation breaks a service, revert the configuration management change, re-run Lynis to record the state, and log a time-boxed exception in
custom.prfrather than silently skipping the test.
Small teams can run Lynis by hand monthly and keep reports in a shared folder. Larger estates need the central pipeline, per-role targets and an owner per finding group; CISOfy's commercial Lynis Enterprise adds central dashboards, but the open source report is enough to build your own.
Detection and measurement
- Coverage: percentage of in-scope Linux and Unix hosts with a privileged Lynis report less than 8 days old.
- Warnings open: count of
warning[]entries per role, with age; aim for zero warnings older than one patch cycle. - Hardening index trend: median and lowest score per role, per Lynis version, month on month.
- Exception hygiene: number of
skip-testlines and the share with an owner and review date. - Drift: findings that reappear after being fixed, which point to a gap in configuration management.
Also alert on a sudden fall in a host's index or a rise in tests_skipped, which can mean a profile change, a broken package audit tool or tampering with the host.
Common failure patterns
- Scoring the unprivileged scan:
--pentestresults are compared with root scans and look better or worse for reasons unrelated to hardening. - Skipping to the target: teams add
skip-testlines until the index meets a KPI. Tie targets to warnings closed, not just the score. - Running an old copy: a stale distribution package misses newer tests and end-of-life data, so results look cleaner than they are.
- Losing history: the log is purged and the report overwritten on every run, so without copies there is no audit trail.
- Fixing by hand: admins correct a finding directly on one host, configuration management reverts it, and the finding returns next week.
- Leaving reports world readable: a report collected to a shared location gives an intruder a map of weak accounts and open ports.
Framework mapping
| Framework | Reference | How Lynis supports it |
|---|---|---|
| NIST SP 800-53 Rev. 5 | CM-6 Configuration Settings; CM-7 Least Functionality | Checks settings and flags unneeded services and compilers |
| NIST SP 800-53 Rev. 5 | RA-5 Vulnerability Monitoring and Scanning; CA-7 Continuous Monitoring | Scheduled host scans with vulnerable package and trend data |
| NIST CSF 2.0 | PR.PS-01; ID.RA-01; DE.CM-09 | Configuration practice evidence, vulnerability identification, runtime monitoring |
| CIS Controls v8.1 | Control 4 Secure Configuration of Enterprise Assets and Software | Verifies the secure configuration process on each host |
| ISO/IEC 27001:2022 Annex A | A.8.8 Management of technical vulnerabilities; A.8.9 Configuration management | Recurring evidence that baselines are applied and reviewed |
Practitioner checklist
- Install a current Lynis release from the CISOfy repository or GitHub and track the version in every report.
- Run privileged
lynis audit systemscans; keep--pentestresults separate. - Create one version-controlled
custom.prfper server role and never editdefault.prf. - Give every
skip-testa reason, an approver and a review date. - Schedule
--cronjobruns and keep timestamped copies of the log and report. - Ship
lynis-report.datto central logging with restricted access and parse warnings, suggestions and the hardening index. - Fail image builds on warnings with
error-on-warnings=yes. - Remediate through configuration management and re-scan to confirm.
- Assign owners to accounts and listening services surfaced in the report.
- Report coverage, open warnings and index trend per role each month.
Standards and references
- CISOfy: Lynis documentation
- CISOfy: Lynis source code and README on GitHub
- CISOfy: Lynis default scan profile (default.prf)
- CISOfy: Lynis changelog
- CISOfy: Lynis product overview
- Linux Audit: Lynis hardening index
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
Related NHI Mgmt Group resources: Linux Server Hardening Guide · CIS Benchmarks Guide · Configuration Drift and Baseline Enforcement Guide · Linux Logging and auditd for Defenders Guide · CIS Controls Guide