Log Files and Journalctl

Another popular log management system is known as journal. Managed by the journald daemon, the
system is designed to centralize the management of logs regardless of where the messages are originating.
In the context of this lab, the most evident feature of the journal system daemon is the use of
append-only binary files serving as its log files.


Step 1. Running journalctl with no options.
a. To look at the journald logs, use the journalctl command. The journalctl tool interprets
and displays the log entries previously stored in the journal binary log files.
```
analyst@secOps ~$ journalctl
-- Logs begin at Fri 2014-09-26 14:13:12 EDT, end at Tue 2017-02-07 13:23:29 ES
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Starting Paths.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Reached target Paths.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Starting Timers.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Reached target Timers.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Starting Sockets.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Reached target Sockets.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Starting Basic System.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Reached target Basic System.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Starting Default.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Reached target Default.
Sep 26 14:13:12 dataAnalyzer systemd[1087]: Startup finished in 18ms.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopping Default.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopped target Default.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopping Basic System.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopped target Basic System.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopping Paths.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopped target Paths.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopping Timers.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopped target Timers.
Sep 26 14:14:24 dataAnalyzer systemd[1087]: Stopping Sockets.

```
b. Use CTRL+C to exit the display.

Step 2. Journalctl and a few options.
Part of the power of using journalctl lies on its options.
a. Use journalctl -utc to display all timestamps in UTC time:
```
analyst@secOps ~$ sudo journalctl –utc
```
b. Use journalctl -b to display log entries recorded during the last boot:
```
analyst@secOps ~$ sudo journalctl –b
Feb 07 08:23:13 secOps systemd-journald[172]: Time spent on flushing to /var is
Feb 07 08:23:13 secOps kernel: Linux version 4.8.12-2-ARCH (builduser@andyrtr)
Feb 07 08:23:13 secOps kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 fl
Feb 07 08:23:13 secOps kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE re
Feb 07 08:23:13 secOps kernel: x86/fpu: Supporting XSAVE feature 0x004: 'AVX re
Feb 07 08:23:13 secOps kernel: x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]
Feb 07 08:23:13 secOps kernel: x86/fpu: Enabled xstate features 0x7, context si
Feb 07 08:23:13 secOps kernel: x86/fpu: Using 'eager' FPU context switches.
Feb 07 08:23:13 secOps kernel: e820: BIOS-provided physical RAM map:

```
c. Use journalctl to specify the service and timeframe for log entries. The command
below shows all nginx service logs recorded today:
```
analyst@secOps ~$ sudo journalctl -u nginx.service --since today
```
d. Use the -k switch to display only messages generated by the kernel:
```
analyst@secOps ~$ sudo journalctl –k
```
e. Similar to tail -f described above, use the -f switch to actively follow the logs as they
are being written:
```
analyst@secOps ~$ sudo journalctl –f
```

Computer Science & Information Technology

You might also like to view...

Which command can you use to see the uptime for a router?

show uptime b. sh uptime c. show time d. show version

Computer Science & Information Technology

Seven elements common to stories told by users in the organization are:

What will be an ideal response?

Computer Science & Information Technology

Why is a basic understanding of Filesystem Hierarchy Standard (FHS) a valuable tool for Linux administrators and users?

What will be an ideal response?

Computer Science & Information Technology

Which is the function body for the Jeopardy constructor?

``` class TVGame { protected: string host; string game; public: TVGame(string h, string g); GoToCommercial(); // add the StartGame function here }; class Jeopardy : public TVGame { private: int score; public: Jeopardy(string h, string g, int s); // add StartGame function here }; ``` A. { s = score; } B. { g = h; } C. { h = score; } D. {score = s;}

Computer Science & Information Technology