Conquer Security Audits: Your Essential Lynis Command Cheat Sheet

Photo by Omkar Patyane on Pexels
Published 24 February 2024 Last updated 15 April 2024 An older guide that hasn't been re-checked yet, so commands or versions may have moved on. How guides are made and checked

This cheat sheet equips you with essential Lynis commands to navigate your system’s security landscape. Quickly learn how to launch basic and advanced scans, filter results by severity or category, and delve deeper into specific tests for comprehensive analysis. With this guide at your fingertips, you’ll be well-positioned to identify vulnerabilities, harden your system, and ensure its ongoing security posture.

This guide is related to Boost Linux Security with Lynis.

Installation:

SystemCommand
Debian/Ubuntusudo apt-get install lynis
CentOS/Fedora/Red Hatsudo dnf install lynis
NixOSnix-shell -p lynis for a temporary installation environment.

Usage:

TaskCommand
Perform an Auditsudo lynis audit system
Perform an Audit for Dockerfileslynis audit dockerfile /path/to/your/Dockerfile
Perform an Audit and Output to Filesudo lynis audit system --output-file=/path/to/output/file
Custom Profilessudo lynis audit system --profile=/path/to/custom/profile
Suppress Warnings/Notificationssudo lynis audit system --no-logs
Generate Report in Text Formatsudo lynis audit system --report-file=/path/to/report/file.txt
Generate Report in HTML Formatsudo lynis audit system --report-file=/path/to/report/file.html
Generate Report in JSON Formatsudo lynis audit system --report-file=/path/to/report/file.json
Automate Auditing (Cron)Edit crontab: sudo crontab -e Add: 0 3 * * * /usr/bin/lynis --cronjob --auditor "Your Name" --no-colors --quiet
Update Lynis Definitionssudo lynis update info
Get Help and Usage Informationlynis --help
Check System Hardeningsudo lynis audit system --tests-category hardening
Check for Security Updatessudo lynis audit system --tests-category updates

Incorporating these Lynis commands into your security routine gives you a powerful ally in safeguarding your system. Security is an ongoing process, so leverage this cheat sheet to assess your system’s health regularly and proactively address potential threats. With vigilance and these valuable commands, you can confidently maintain a robust security posture and navigate the ever-evolving digital landscape.