It’s impossible to imagine a user and server administrator, or even a Linux-based workstation who never read the log files. The operating system and running applications constantly create various types of messages that are recorded in various log files. The ability to determine the desired log file and what to look for in it will help save time and eliminate the error faster.
Logging is the main source of information on the operation of the system and its errors. In this quick start guide, we will look at the main aspects of operating system logging, the directory structure, programs for reading and reviewing logs.
All log files can be attributed to one of the following categories:
Most of the log files are contained in the /var/log
directory.
--level=
you can filter the output by the criterion of significance. (): emerg - alert - crit - err - warn - notice - , info - debug - (5:520)$ dmesg -l err [1131424.604352] usb 1-1.1: 2:1: cannot get freq at ep 0x1 [1131424.666013] usb 1-1.1: 1:1: cannot get freq at ep 0x81 [1131424.749378] usb 1-1.1: 1:1: cannot get freq at ep 0x81
update-alternatives
program, which contains symbolic links to default commands or libraries.auditd
.crond
service report about the commands being executed and messages from the commands themselves.faillog
.Samba
file server, which is used to access Windows shared folders and provide Windows users access to Linux shared folders.For each distribution there will be a separate package manager log.
Yum
on RedHat Linux.ebuild
installed from Portage
using emerge
in Gentoo Linux.dpkg
on Debian Linux and the entire family of related distributions.And some binary logs of user sessions.
last
.pam_tally2
utility.utmpdump
command. (5:535)$ sudo utmpdump /var/log/wtmp [5] [02187] [l0 ] [ ] [4.0.5-gentoo ] [0.0.0.0 ] [ 11 16:50:07 2015] [1] [00000] [~~ ] [shutdown] [4.0.5-gentoo ] [0.0.0.0 ] [ 11 16:50:08 2015] [2] [00000] [~~ ] [reboot ] [3.18.12-gentoo ] [0.0.0.0 ] [ 11 16:50:57 2015] [8] [00368] [rc ] [ ] [3.18.12-gentoo ] [0.0.0.0 ] [ 11 16:50:57 2015] [1] [20019] [~~ ] [runlevel] [3.18.12-gentoo ] [0.0.0.0 ] [ 11 16:50:57 2015]
Since the operating system, even such a wonderful one as Linux, does not in itself carry any tangible benefit in itself, most likely a database, a web server, and various applications will run on the server or workstation. Each application or service can have its own file or directory of event and error logs. Naturally it is impossible to list them all, only some.
access_log
, and errors are in the error_log
.Graphic application logs, DE, can be located in the user's home directory.
stderr
X11 graphics applications. Initializing "kcm_input" : "kcminit_mouse" Initializing "kcm_access" : "kcminit_access" Initializing "kcm_kgamma" : "kcminit_kgamma" QXcbConnection: XCB error: 3 (BadWindow), sequence: 181, resource id: 10486050, major code: 20 (GetProperty), minor code: 0 kf5.kcoreaddons.kaboutdata: Could not initialize the equivalent properties of Q*Application: no instance (yet) existing. QXcbConnection: XCB error: 3 (BadWindow), sequence: 181, resource id: 10486050, major code: 20 (GetProperty), minor code: 0 Qt: Session management error: networkIdsList argument is NULL
Almost everyone knows about the less
utility and the tail -f
command. Also for these purposes, the vim
editor and the Midnight Commander file manager will fit. Everyone has their drawbacks: less
doesn’t handle long-line journals, taking them as binary. Midnight Commander is suitable only for a quick look, when there is no need to search for a complex pattern and move back and forth between matches. The vim
editor understands and highlights the syntax of many formats, but if the log is updated frequently, then there are distracting messages about changes in the file. However, this can be easily circumvented with <:view /path/to/file>
.
Recently, I discovered another valid and promising, but slightly still damp, utility - lnav , in decryption of the Log File Navigator.
Install the package as usual with one command.
$ aptitude install lnav #Debian/Ubuntu/LinuxMint $ yum install lnav #RedHat/CentOS $ dnf install lnav #Fedora $ emerge -av lnav #Gentoo, package.accept_keywords $ yaourt -S lnav #Arch
The log navigator lnav understands a number of file formats.
What does understanding file formats mean in this case? The trick is that lnav is more than a utility for viewing text files. The program can do something else. You can open multiple files at once and switch between them.
(5:471)$ sudo lnav /var/log/pm-powersave.log /var/log/pm-suspend.log
The program can directly open the archive file.
(5:471)$ lnav -r /var/log/Xorg.0.log.old.gz
Displays a histogram of informative messages, warnings, and errors when you press the <i>
key. This is from my syslog.
Mon May 02 20:25:00 123 normal 3 errors 0 warnings 0 marks Mon May 02 22:40:00 2 normal 0 errors 0 warnings 0 marks Mon May 02 23:25:00 10 normal 0 errors 0 warnings 0 marks Tue May 03 07:25:00 96 normal 3 errors 0 warnings 0 marks Tue May 03 23:50:00 10 normal 0 errors 0 warnings 0 marks Wed May 04 07:40:00 96 normal 3 errors 0 warnings 0 marks Wed May 04 08:30:00 2 normal 0 errors 0 warnings 0 marks Wed May 04 10:40:00 10 normal 0 errors 0 warnings 0 marks Wed May 04 11:50:00 126 normal 2 errors 1 warnings 0 marks
In addition, syntax highlighting, tab addition and various utilities in the status line are supported. The disadvantages include unstable behavior and freezes. I hope lnav will be actively developed, a very useful program in my opinion.
Source: https://habr.com/ru/post/332502/
All Articles