Lynis : Security Auditing Tool for Unix/Linux Systems

Lynis is a security auditing tool for UNIX derivatives like Linux, macOS, BSD, Solaris, AIX, and others. It performs an in-depth security scan. Software packages is available by clicking here.

Requirements

Shell and basic utilities

Permissions

Normal user or preferable root permissions

Installation

Installation via package

Installing the tool via a package manager is one option to get started with it. For most operating systems and distributions, a port or package is available.

First add our software repository. This way the latest version will be available to your system.

Red Hat

This applies to systems running YUM, including CentOS, Fedora, Red Hat Enterprise Linux (RHEL).

Also Read – Leviathan : Wide Range Mass Audit Toolkit

$ yum install lynis

Debian

Systems running Debian, Linux Mint, Ubuntu, or are based on one of these.

$ apt-get install lynis

openSUSE

$ zypper install lynis

Installation via Git

Clone project

The first step is cloning the project. Before doing so, select the parent directory. Git will create a subdirectory with the full program in it.

$ cd /usr/local

$ git clone https://github.com/CISOfy/lynis
Cloning into ‘lynis’…
remote: Counting objects: 1733, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 1733 (delta 3), reused 0 (delta 0), pack-reused 1725
Receiving objects: 100% (1733/1733), 886.18 KiB | 378.00 KiB/s, done.
Resolving deltas: 100% (1204/1204), done.
Checking connectivity… done.

$ cd lynis

That is it. Time to run your first security audit:

$ lynis audit system

Although no configuration is required, there are a few useful commands to learn.

Installation via direct download

  • Create a directory

It can be started from each directory. So choose a directory where you want to store the tool. For our example purpose we use /usr/local/lynis, as the /usr/local directory exists on most distributions.

$ mkdir -p /usr/local/lynis
$ cd /usr/local

  • Download

Next step is downloading the latest version of the tool into the /usr/local directory. In this method we use the compressed tarball, which is an archive of all files.

Go to the tool download page. Copy the link to the tarball (ends with tar.gz).

Use this link together with wget (usually installed by default). macOS users can use curl tool, where BSD users could use fetch.

$ wget https://cisofy.com/files/lynis-.tar.gz

or

$ curl https://cisofy.com/files/lynis-.tar.gz -o lynis.tar.gz

  • Unpack the tarball

$ tar xfvz lynis-.tar.gz

Installation via Homebrew

For users of macOS, Homebrew can be used as an alternative to manual installation and using Git.

$ brew install lynis

After the installation with Homebrew, it is time to run it for the first time.

Running

If the tool was installed via a package or Homebrew, you can run it from any directory.

For the other methods, ensure that you are in the right directory and add ‘./’ in front of the command, like:

$ ./lynis

It can run without any preconfiguration. Configuration and fine-tuning is possible though and will be covered in later sections. For now we will run a basic scan:

$ lynis audit system

Lynis and Pauses

By default it starts and pauses after the first section. With CTRL+C you can stop the program. With ENTER it will continue to the next set of tests. If we want to run it without any pauses, we could give it an additional parameter: –quick. This will enable the “quick” option, ideal for running it while you do other things.

$ lynis audit system –quick

Features

It is security auditing tool, for Unix, Linux and macOS systems.
It is used by system administrators, auditors and security professionals, all over the world. Some of the features are:

Basics

  • Open source
  • Shell script
  • No dependencies
  • Easy to understand

Support

  • Dynamic OS detection
  • 300+ built-in tests
  • Support for custom tests
  • Plugin support
  • Compliance checks
  • Extensive software support

Reporting

  • Report on screen and details in report file
  • Reporting of warnings and suggestions
  • Detailed logging
  • Hardening index
R K

Recent Posts

Bash Scripting Best Practices Every Beginner Should Know

Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…

1 day ago

How To Create A Self-Signed SSL Certificate Using Bash And OpenSSL

Introduction A self-signed SSL certificate is a certificate that is created and signed by the…

1 day ago

How To Debug Bash Scripts Using bash -x And set Commands

Introduction Debugging is an important part of Bash scripting. When a script does not work…

1 day ago

How To Use Cron Jobs With Bash Scripts For Automation

Introduction Cron jobs are used in Linux to run commands or Bash scripts automatically at…

1 day ago

How To Use Pipes In Bash Scripts For Command Chaining

Introduction Pipes are an important feature in Linux and Bash scripting. A pipe allows you…

1 day ago

How To Use grep, awk, And sed In Bash Scripts

Introduction The grep, awk, and sed commands are powerful text-processing tools in Linux. They are…

2 days ago