lynis
Lynis - Security auditing tool for Linux, macOS, and UNIX-based systems. Assists with compliance testing (HIPAA/ISO27001/PCI DSS) and system hardening. Agentless, and installation optional.
Top Related Projects
CrowdSec - the open-source and participative security solution offering crowdsourced protection against malicious IPs and access to the most advanced real-world CTI.
Wazuh - The Open Source Security Platform. Unified XDR and SIEM protection for endpoints and cloud workloads.
A vulnerability scanner for container images and filesystems
Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
NIST Certified SCAP 1.2 toolkit
Quick Overview
Lynis is an open-source security auditing tool designed for Unix-based systems, including Linux, macOS, and others. It performs comprehensive system checks, assessing security defenses and providing recommendations for system hardening. Lynis is widely used by system administrators and security professionals to improve the security posture of their systems.
Pros
- Comprehensive security scanning with over 300 tests
- Easily extensible through plugins and custom tests
- Lightweight and requires no installation (can run from a USB drive)
- Generates detailed reports in various formats (text, CSV, JSON)
Cons
- Can be overwhelming for beginners due to the extensive output
- Some tests may produce false positives or require manual verification
- Limited graphical interface options (primarily command-line based)
- May require root access for full functionality, which can be a security concern
Getting Started
To get started with Lynis:
-
Clone the repository:
git clone https://github.com/CISOfy/lynis
-
Navigate to the Lynis directory:
cd lynis
-
Run Lynis with root privileges:
sudo ./lynis audit system
-
Review the output and generated report (typically in
/var/log/lynis.log
)
For more options and customization, refer to the official documentation on the GitHub repository.
Competitor Comparisons
CrowdSec - the open-source and participative security solution offering crowdsourced protection against malicious IPs and access to the most advanced real-world CTI.
Pros of CrowdSec
- Real-time threat detection and response capabilities
- Community-driven approach, leveraging collective intelligence
- Supports multiple services and platforms beyond just Linux
Cons of CrowdSec
- More complex setup and configuration compared to Lynis
- Requires ongoing maintenance and updates for optimal performance
- May have higher resource usage due to real-time monitoring
Code Comparison
Lynis (shell script):
#!/bin/sh
# Lynis - Security auditing and system hardening for Linux and UNIX
# Copyright 2007-2013, Michael Boelen (michael.boelen@cisofy.com)
# Web site: https://cisofy.com/
CrowdSec (Go):
package main
import (
"github.com/crowdsecurity/crowdsec/cmd"
)
func main() {
cmd.Execute()
}
While Lynis is primarily a shell script for auditing and hardening systems, CrowdSec is a more comprehensive Go-based application focused on real-time threat detection and response. Lynis is simpler to use and requires less setup, but CrowdSec offers more advanced features and broader platform support. The choice between them depends on specific security needs and available resources.
Wazuh - The Open Source Security Platform. Unified XDR and SIEM protection for endpoints and cloud workloads.
Pros of Wazuh
- Comprehensive security platform with SIEM, IDS, and vulnerability detection capabilities
- Real-time monitoring and alerting for multiple operating systems and cloud environments
- Scalable architecture suitable for large enterprise deployments
Cons of Wazuh
- More complex setup and configuration compared to Lynis
- Higher resource requirements due to its extensive feature set
- Steeper learning curve for new users
Code Comparison
Lynis (shell script):
#!/bin/sh
# Lynis - Security auditing and system hardening for Linux and UNIX
# Copyright 2007-2013, Michael Boelen (michael.boelen@cisofy.com)
# Web site: https://cisofy.com/lynis/
Wazuh (C):
/* Copyright (C) 2015, Wazuh Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation.
*/
Lynis is a lightweight, single-file shell script focused on security auditing and system hardening for Linux and UNIX systems. It's easy to use and requires minimal setup. Wazuh, on the other hand, is a more comprehensive security platform written in C, offering a wide range of features including SIEM, IDS, and vulnerability detection. While Wazuh provides more extensive capabilities, it also requires more resources and has a steeper learning curve compared to Lynis.
A vulnerability scanner for container images and filesystems
Pros of Grype
- Specialized in container and application vulnerability scanning
- Faster scanning speed for container images and filesystems
- Integrates well with CI/CD pipelines and container registries
Cons of Grype
- Limited to vulnerability scanning, lacks system hardening features
- Narrower scope compared to Lynis' comprehensive system auditing
- Requires more setup for non-container environments
Code Comparison
Lynis (bash script):
#!/bin/bash
# Lynis security auditing tool
# https://cisofy.com/lynis/
# Perform system audit
perform_audit() {
# ... (audit logic)
}
Grype (Go):
package cmd
import (
"github.com/anchore/grype/grype"
"github.com/spf13/cobra"
)
func NewRootCmd() *cobra.Command {
// ... (command setup)
}
Summary
Grype focuses on container and application vulnerability scanning, offering faster performance and better integration with container ecosystems. Lynis provides a more comprehensive system auditing approach, covering a broader range of security aspects but with less specialization in container environments. Grype is written in Go, while Lynis is a bash script, reflecting their different design philosophies and target use cases.
Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more
Pros of Trivy
- Specialized in container and infrastructure scanning
- Faster scanning speed for container images
- Broader vulnerability database coverage
Cons of Trivy
- Less comprehensive system auditing capabilities
- Primarily focused on vulnerabilities, less on system hardening
- Newer project with potentially less mature codebase
Code Comparison
Lynis (system auditing):
#!/bin/sh
# Lynis - Security auditing and system hardening for Linux and UNIX
# Copyright 2007-2013, Michael Boelen (michael.boelen@cisofy.com)
# Web site: https://cisofy.com/
Trivy (container scanning):
package main
import (
"github.com/aquasecurity/trivy/pkg/commands"
)
func main() {
commands.Execute()
}
Summary
Lynis is a comprehensive system auditing tool for Unix-like systems, focusing on security hardening and compliance. Trivy, on the other hand, specializes in container and infrastructure scanning, with a primary focus on vulnerability detection. While Trivy offers faster scanning for containers and a broader vulnerability database, Lynis provides more extensive system auditing capabilities and a mature codebase. The choice between the two depends on specific use cases and requirements.
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
Pros of ansible-collection-hardening
- Automated deployment and configuration management using Ansible
- Modular approach allows for selective hardening of specific components
- Supports multiple operating systems and platforms
Cons of ansible-collection-hardening
- Requires Ansible knowledge and infrastructure setup
- May have a steeper learning curve for users unfamiliar with Ansible
- Less comprehensive in terms of security checks compared to Lynis
Code Comparison
Lynis (bash script):
# Check if package manager is available
if [ -x /usr/bin/apt-get ]; then
PACKAGE_MANAGER="apt-get"
elif [ -x /usr/bin/yum ]; then
PACKAGE_MANAGER="yum"
fi
ansible-collection-hardening (Ansible task):
- name: Install security packages
package:
name: "{{ security_packages }}"
state: present
when: ansible_os_family in ['Debian', 'RedHat']
The code snippets demonstrate the different approaches:
- Lynis uses bash scripting to detect the package manager
- ansible-collection-hardening leverages Ansible's built-in package module for cross-platform compatibility
Both tools aim to enhance system security, but Lynis focuses on auditing and reporting, while ansible-collection-hardening emphasizes automated configuration and hardening across multiple systems.
NIST Certified SCAP 1.2 toolkit
Pros of OpenSCAP
- More comprehensive security compliance checks, supporting multiple standards (NIST, DISA STIG, PCI-DSS)
- Robust reporting capabilities with XML and HTML output options
- Extensible through OVAL and XCCDF content
Cons of OpenSCAP
- Steeper learning curve and more complex setup
- Primarily focused on Red Hat-based systems, less versatile across different distributions
- Requires more system resources to run
Code Comparison
OpenSCAP (using oscap command-line tool):
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_pci-dss --results scan-results.xml --report scan-report.html /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml
Lynis:
lynis audit system
OpenSCAP offers more detailed configuration options and supports specific compliance profiles, while Lynis provides a simpler, more straightforward command for general system auditing.
Both tools are valuable for system security assessment, with OpenSCAP being more suited for enterprise environments with specific compliance requirements, and Lynis offering a lighter, more portable solution for quick security checks across various Unix-based systems.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Do you like this software? Star the project and become a stargazer.
lynis
Lynis - Security auditing and hardening tool, for UNIX-based systems.
Lynis is a security auditing tool for systems based on UNIX like Linux, macOS, BSD, and others. It performs an in-depth security scan and runs on the system itself. The primary goal is to test security defenses and provide tips for further system hardening. It will also scan for general system information, vulnerable software packages, and possible configuration issues. Lynis was commonly used by system administrators and auditors to assess the security defenses of their systems. Besides the "blue team," nowadays penetration testers also have Lynis in their toolkit.
We believe software should be simple, updated on a regular basis, and open. You should be able to trust, understand, and have the option to change the software. Many agree with us, as the software is being used by thousands every day to protect their systems.
Goals
The main goals are:
- Automated security auditing
- Compliance testing (e.g. ISO27001, PCI-DSS, HIPAA)
- Vulnerability detection
The software (also) assists with:
- Configuration and asset management
- Software patch management
- System hardening
- Penetration testing (privilege escalation)
- Intrusion detection
Audience
Typical users of the software:
- System administrators
- Auditors
- Security officers
- Penetration testers
- Security professionals
Installation
There are multiple options available to install Lynis.
Software Package
For systems running Linux, BSD, and macOS, there is typically a package available. This is the preferred method of obtaining Lynis, as it is quick to install and easy to update. The Lynis project itself also provides packages in RPM or DEB format suitable for systems systems running:
CentOS
, Debian
, Fedora
, OEL
, openSUSE
, RHEL
, Ubuntu
, and others.
Some distributions may also have Lynis in their software repository:
Note: Some distributions don't provide an up-to-date version. In that case it is better to use the CISOfy software repository, download the tarball from the website, or download the latest GitHub release.
Git
The very latest developments can be obtained via git.
-
Clone or download the project files (no compilation nor installation is required) ;
git clone https://github.com/CISOfy/lynis
-
Execute:
cd lynis && ./lynis audit system
If you want to run the software as root
(or sudo), we suggest changing the ownership of the files. Use chown -R 0:0
to recursively alter the owner and group and set it to user ID 0
(root
). Otherwise Lynis will warn you about the file permissions. After all, you are executing files owned by a non-privileged user.
Enterprise Version
This software component is also part of an enterprise solution. Same quality, yet with more functionality.
Focus areas include compliance (PCI DSS
, HIPAA
, ISO27001
, and others). The Enterprise version comes with:
- a web interface;
- dashboard and reporting;
- hardening snippets;
- improvement plan (based on risk);
- commercial support.
Documentation
Full documentation: https://cisofy.com/documentation/lynis/.
Customization
If you want to create your own tests, have a look at the Lynis software development kit.
Security
We participate in the CII best practices badge program of the Linux Foundation.
Media and Awards
Lynis is collecting some awards along the way and we are proud of that.
-
2016
- Best of Open Source Software Awards 2016.
- Article by TechRepublic, considering Lynis a "must-have" tool: How to quickly audit a Linux system from the command line
-
2015
-
2014
-
2013
Contribute
We love contributors.
Do you have something to share? Want to help out with translating Lynis into your own language? Create an issue or pull request on GitHub, or send us an e-mail: lynis-dev@cisofy.com.
More details can be found in the Contributors Guide.
You can also simply contribute to the project by starring the project and show your appreciation that way.
Thanks!
License
GPLv3
Top Related Projects
CrowdSec - the open-source and participative security solution offering crowdsourced protection against malicious IPs and access to the most advanced real-world CTI.
Wazuh - The Open Source Security Platform. Unified XDR and SIEM protection for endpoints and cloud workloads.
A vulnerability scanner for container images and filesystems
Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
NIST Certified SCAP 1.2 toolkit
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot