Viewing System Logs in Kali Linux
In this first step, you will learn how to view system logs within a Kali Linux container on the LabEx VM. System logs are critical for monitoring and troubleshooting issues on a Linux system, as they record events, errors, and activities. As a beginner, understanding how to access these logs is a foundational skill for system administration.
When you open the terminal in the LabEx VM environment, you will be automatically connected to the Kali Linux container's shell. There is no need to manually start the container or enter the shell; the environment is already set up for you. All operations in this lab will be performed within this container's terminal.
Linux systems store logs in directories like /var/log
. Common log files include /var/log/syslog
for general system messages and /var/log/auth.log
for authentication-related events. Let's start by viewing the contents of these files using simple commands.
Run the following command in the terminal to display the last 10 lines of the /var/log/syslog
file:
tail -n 10 /var/log/syslog
This command uses tail
to show the most recent entries in the log file. The output will look something like this, though the exact content depends on your system's activity:
Oct 15 10:22:34 kali-container kernel: [ 1234.567890] some kernel message
Oct 15 10:23:01 kali-container cron[1234]: (CRON) INFO (pidfile fd = 3)
...
Each line typically includes a timestamp, hostname, service or process name, and the event details. This output confirms that you have successfully accessed the system logs.
To continuously monitor new log entries in real-time, which is useful for debugging, run this command:
tail -f /var/log/syslog
This will display new entries as they are added. To stop monitoring, press Ctrl + C
to return to the terminal prompt.
Next, let's check the authentication log file /var/log/auth.log
, which records login attempts and other security events. Run this command:
tail -n 5 /var/log/auth.log
The output might look like this, showing authentication-related activities:
Oct 15 10:20:01 kali-container sudo: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/bash
...
This step introduces you to viewing logs, a basic but essential skill. In the following steps, you will build on this by filtering and analyzing these logs for specific information.