Categories: Ubuntu

How to Install Lynis for Security on Ubuntu 22.04

Lynis is the CLI tool that is used for security auditing, system hardening, detecting vulnerabilities, etc. It scans the complete system to evaluate the vulnerabilities, configuration errors, service security, improper file system permissions, etc. You can use this system security-auditing tool on both macOS and Linux.

Lynis helps you to keep the system clean, secure, and invulnerable to improve the system’s performance. However, Lyns is more than what you think because setting up Lynis in Linux is tricky. In this tutorial, we will explain how to install and set up Lynis on Ubuntu 22.04.

How to Install Lynis for Security on Ubuntu 22.04

Installing Lynis on Ubuntu is simple and easy since multiple methods exist. Hence, let’s discuss all these methods:

Install Lynis from the Official Repository of Ubuntu

First, update the system as per the latest updates available for Ubuntu 22.04:

sudo apt update
sudo apt upgrade

Once you are done, run the following command to install the official repository of Lynis:

sudo apt-get -y install lynis

Install the Stable Version of Lynis

If you want to download the stable and latest version of Lynis, run the following command to retrieve the GPG key:

wget -O – https://packages.cisofy.com/keys/cisofy-software-public.key | sudo apt-key add

After running the previous command, add the GPG key through the following command:

echo “deb https://packages.cisofy.com/community/lynis/deb/ stable main” | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list

Once you are done, refresh the APT by executing the following command:

sudo apt update

Finally, install the Lynis in your system:

sudo apt install lynis

How to Use Lynis in Ubuntu

Let’s start the process by checking the currently available version of Lynis in the system:

lynis –version

You can also run the following command to display all the available options and commands for Lynis:

lynis show commands

Now, we can perform the system security auditing by executing the following command:

sudo lynis audit system

After the successful audit, the system saves the scan report in the /var/log/lynis-report.dat. Hence, you can check the report by running the following command:

sudo grep -E “^warning|^suggestion” /var/log/lynis-report.dat

We used the words like warning and suggestion to get a brief detail about the system.

How to Uninstall Lynis

If you want to uninstall Lyins, you can run the following command in the terminal:

sudo apt remove lynis

Moreover, you can remove all the Lynis-related logs through the following command:

sudo rm -rf /var/log/lynis*

Conclusion

This tutorial is about the simple ways to install Lynis for security on Ubuntu 22.04. Lynis is an essential tool to get more details about the system. We explained the different ways to install Lynis and a simple approach to perform the system auditing right from the terminal. Furthermore, we also briefed you about the method to quickly install Lynis.

Ubuntu Server Admin

Recent Posts

Meet the wildlife conservation AI 5G hotspot at MWC Barcelona 2026

From March 2-5 in Barcelona, Canonical will present a working wildlife conservation platform that combines…

7 hours ago

Canonical and Ubuntu RISC-V: a 2025 retro and looking forward to 2026

2025: From RISC-V enablement to real execution  2025 was the year that RISC-V readiness gave…

1 day ago

Unmasking the Resolute Raccoon

You’ve almost certainly seen them… In the forest, rummaging through a dumpster, in poorly aging…

1 day ago

Bad Voltage Season 1 Episode 43: Got The Om On

Jono Bacon, Stuart Langridge and myself present Bad Voltage, in which Bryan is sadly unavoidably…

4 days ago

2011 LinuxQuestions.org Members Choice Award Winners – Thoughts

The polls are closed and the official results are in. You can view the detailed…

4 days ago

Building quantum-safe telecom infrastructure for 5G and beyond

coRAN Labs and Canonical at MWC Barcelona 2026 At MWC Barcelona 2026, coRAN Labs and…

4 days ago