Linux Log Files or /var/log

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-log-files-varlog/
PINTEREST
PINTEREST
INSTAGRAM

Linux provides a lot of different type of logs by default. These files are generally located at /var/log . There may be some exceptions like third party applications but configuration of log location can be change to the /var/log directory. In this post we will look default log files and how to list, tail, search, filter these logs.

List Log Files

Logs files can be simply listed by using ls command but keep in mind there are directories they contain different files for logs.

We can list in a recursive manner to get files and folder under /var/log directory like below.

Reading Log Files

There are  different methods to read log file but we will use less which have practical solutions while reading log file.

Space will skip to next page also page up / page down will work too.

Searching Log File

Less have functionality to search a text file where in this situation a log file. After opening a log files with less use /auth to search “auth” term down to the file pages.

To continue to search term without entering again and again press for the next match or for previous search. After arriving to the file end if no match exist we will get a message like below at the end of terminal.

Filtering Log File

Searhcing is a way to see occurences in a log file and previous and next events. Alternative is filtering log files. Grep is very capable tool to filter log files. We will filter for “auth” for all files named auth.log* . We named files auth.log* because old auth.log files are gzipped and have gz extension.

LEARN MORE  Understanding and Configuring Apache Access Log

If we want to colorize findings we can use normal grep with the same filter term liek below.

Filter All Log Files

Actually filtering or search all files are not different but as an example we can look it by specifying and IP address.

We can use less for search other terms like username “ismail”

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-log-files-varlog/
PINTEREST
PINTEREST
INSTAGRAM