Introduction
Lynis is an open-source security auditing tool. Used by system administrators, security professionals, and auditors to evaluate the security defenses of their Linux and UNIX-based systems. It runs on the host itself, so it performs more extensive security scans than vulnerability scanners.
The "Ubuntu 24.04" template has been installed on the server.
However, it should work with our other Ubuntu templates.
1. Starting from the system update
Run the command as below:
sudo apt update
sudo apt upgrade
2. Configuring and installing Lynis
To install the official repository of Lynis:
sudo apt-get -y install lynis
To download the stable and latest version of Lynis:
wget -O - https://packages.cisofy.com/keys/cisofy-software-public.key | sudo apt-key add β
After installing the stable version, 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
Output example:
Once it's done, refresh the APT by executing the following command:
sudo apt update
Now, we can install Lynis:
sudo apt install lynis
Output example:
To see available Lynis commands:
lynis show commands
Output example:
To perform the system security check:
sudo lynis audit system
Output example:
A log file with completed audit details will be stored on /var/log/lynis-report.dat
, and we can open it with the command:
sudo grep -E "^warning|^suggestion" /var/log/lynis-report.dat
3. Uninstall Lynis
To uninstall Lynis, run:
sudo apt remove lynis
To remove all Lynis-related logs:
sudo rm -rf /var/log/lynis*
That's it. The Lynis has been removed together with its logs.