How to install and use lnav on CentOS 7

lnav on CentOS 7

Introduction

lnav, which stands for Log File Navigator, is a CLI-log file viewer built for small scale solutions. It is totally free, easy to use and customizable.
As all sysadmins know, GNU/Linux stores log files in the /var/log directory. So if any problems occur, the admin need to open and read various log files in that directory. In the absence of any additional tools, it is sometimes impossible to know which log file will contain the most relevant information, which necessitates manually going through all files, viewing their time-stamps and trying to diagnose the problem. This is a monotonous and time consuming task that you do not want to find yourself doing! Thankfully, with lnav sysadmins home users can accomplish this task simply and quickly. Let’s look at how to install lnav on CentOS 7.

Installing lnav on Centos 7

Installation is easy as reading this line. There are two ways:

  • through EPEL-repository
  • building from source
Using EPEL-repository

If not yet present, install the EPEL repository with:

# yum install epel-release

and then install the utility:

# yum install lnav

It’s a light piece of software (just 1.1MB) so it will be almost instantaneous.

Building from source

Download the source code:

$ wget https://github.com/tstack/lnav/releases/download/v0.8.1/lnav-0.8.1.tar.gz

Extract it with:

tar xf lnav-0.8.1.tar.gz

Lnav requires the following software packages:

  • libpcre – The Perl Compatible Regular Expression (PCRE) library
  • sqlite – The SQLite database engine
  • ncurses – The ncurses text UI library
  • readline – The readline line editing library
  • zlib – The zlib compression library
  • bz2 – The bzip2 compression library
  • re2c – The re2c scanner generator
  • libcurl – The cURL library for downloading files from URLs. Version 7.23.0 or higher is required

Next:

$ cd lnav-0.8.1
$ mkdir release
$ cd release
$ ../configure --prefix=/usr/local
$ make
# make install

Using lnav

Let’s first look at all the options taken by lnav:

usage: lnav [options] [logfile1 logfile2 ...]

A curses-based log file viewer that indexes log messages by type
and time to make it easier to navigate through files quickly.

Key bindings:
  ?     View/leave the online help text.
  q     Quit the program.

Options:
  -h         Print this message, then exit.
  -H         Display the internal help text.
  -I path    An additional configuration directory.
  -i         Install the given format files and exit.
  -C         Check configuration and then exit.
  -d file    Write debug messages to the given file.
  -V         Print version information.

  -a         Load all of the most recent log file types.
  -r         Load older rotated log files as well.
  -t         Prepend timestamps to the lines of data being read in
             on the standard input.
  -w file    Write the contents of the standard input to this file.

  -c cmd     Execute a command after the files have been loaded.
  -f path    Execute the commands in the given file.
  -n         Run without the curses UI. (headless mode)
  -q         Do not print the log messages after executing all
             of the commands or when lnav is reading from stdin.

Optional arguments:
  logfile1          The log files or directories to view.  If a
                    directory is given, all of the files in the
                    directory will be loaded.

Examples:
  To load and follow the syslog file:
    $ lnav

  To load all of the files in /var/log:
    $ lnav /var/log

  To watch the output of make with timestamps prepended:
    $ make 2>&1 | lnav -t
Running without arguments

As root, run lnav without arguments:

# lnav

It will open /var/log/messages log file, as in this screen:
1

The above command filtered log files for all <code>/var/log/</code> folders, as can be seen. It’s also possible to “specialize” the analysis to one directory. For instance:

# lnav /var/log/cups

The same thing can be done from inside a running session of lnav.

# lnav

Next, hit :open /var/log/cups . Without closing the program, it will display CUPS log file informations. It can then be closed with q ,which shows an interesting thing: lnav implements some keybindings from the VI text editor. To navigate inside a log file, admins can use h,j,k,l keys or arrow keys.

Old rotated log files

Sometimes, the informations are not available in the most recent files and it’s necessary to look into old log files. In these cases, use the -r option.

# lnav -r

Conclusions

This rapid overview has demonstrated how inspecting log files in a small scale system can be made easier by using this free and lightweight tool. It is available for all *nix platforms, so why not go ahead and use it! Everyone likes to avoid a headache…

  • jacqueline.burton

    I was paid 104000 dollars last 12 months by doing a web based task moreover I was able to do it by w­orking in my own time f­o­r quite a few hours during the day. I used work opportunity I found out on the internet and so I am excited that I was capable to make such good money. It is genuinely newbie-friendly and I am so blessed that I found out about it. Check out what I do… http://secure10­.­weebly­.­com

  • christine.mccroy

    I was paid 104000 bucks last 12 month period by doing a web-based task while I was able to do it by w­orking in my own time f­o­r quite a few hours during the day. I tried job opportunity I found out over the internet and I am excited that I was manage to make such decent cash. It is really newbie-friendly and therefore I am so pleased that I discovered out about it. Look out for what I do… http://nubr­.­co/QUp3qK

  • I was paid 104000 dollars previous 12 months by doing an on-line job and I was able to do it by w­orking in my own time f­o­r quite a few hours regularly. I used work opportunity I found out over the internet and I am thrilled that I was in the position to make such decent earnings. It is seriously newbie-friendly and I’m so grateful that I discovered out regarding it. Look into what I do… http://urll­.­in/Ohhu2

  • I was paid 104000 bucks past year by doing an internet job and also I was able to do it by w­orking in my own time f­o­r several hours during the day. I used job opportunity I found over the internet and therefore I am excited that I was capable to make such great money. It’s really newbie-friendly and therefore I am so delighted that I discovered out about it. Take a look at exactly what I do… http://ipt­.­pw/Anw9t9

  • mobley.barbara

    I was without work for half a year when my early Fellow worker lastly strongly recommended me to get into freelancing online… It was just after I earned $5000 in my initial 30 days when I seriously believed I am able to do this for a living! Today I am joyful than ever… I work from home moreover I am my own boss now like I always wanted… I see several unhappy people around me, working the same old boring job that is sucking the life out of all of them day by day… Whenever I see some-one like that I say START FREELANCING MAN! This is where I started >>>> http://flicom­.­ru/295837

  • I was paid 104000 dollars past 12 months by doing an internet work and also I was able to do it by w­orking in my own time f­o­r several hours each day. I utilized job opportunity I stumbled upon online and also I am thrilled that I was manage to earn such great money. It is really newbie-friendly and I am so grateful that I found out regarding it. Look into exactly what I do… http://olaurl­.­com/15cnh

  • Chief executive officer of Google!, is advising users to get into “Work at home” practice, that Thousands of marketers have been doing more than one year now. This year alone, I made around $36k until now with nothing but my PC as well as some extra time, despite that i have a regular nine to five job. Even most people newbie in this, can earn $50/per h successfully and the profit can go even very high with time… This is how i started >> http://adultadda­.­net/2Xm

  • M­a­n­y p­e­o­ple desire t­o ha­v­e a go­o­d earnings at their, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a many w­ays t­o ea­rn large am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, Thus I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 monthly since 12 months.Its a web-based job and also hassle-free to do, Even a little boy or girl can do this work and make money on the internet. If you want a happy and wealthy life then you need to copy and paste this internet site in browser and then follow instructions to get started today and earn Thousands Online……….. http://ipt­.­pw/pmpUD3

  • M­a­n­y p­e­o­ple wish t­o ha­v­e a go­o­d in­com­e at their, bu­t t­he­y don’t have much idea ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn big am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a fraud, Thus Now I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 each month since 12 months.Its an online work and also very easy to do, Even a little child can do this work and make money online. If you want a happy and rich life then you should copy and paste this site in browser and then follow instructions to get started today and make Thousands On-line……….. http://v15­.­uk/defFa

  • I have been on numerous systems but nothing worked well for me in a proper manner. And finally in 2012 I discovered a system that is crazy. It is quite simple and easy to setup and I began promoting it within few mins.This program works and is perfect for almost everyone regardless of age group,educational background or professional skills.You can get instant results even if you feel like you have sup-par computer skills.I have earned $1000 in my initial 7-day period and after that I am earning $10000 or more each and every month.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//1v

  • If you’re trying to find stable on line home-business venture but yet tired of on-line gimmicks then this is really for you. I’am working on this project 2 yrs and I am obtaining Seven Thousand bucks or over every mnth very easily. Start making money just like me… Check out info >>>>>>>>>>> http://v15­.­uk/mfSiq

  • Profiting through online can be as plain and simple (as well as very difficult) as making extra money off the net. While a large number The world of internet marketing analysts declare to have a hidden knowledge model to earn quick profit, the the reality is, you cannot find any process you actually can become wealthy overnight through clicking on a key or just getting yourself a few handbook. Making money over the internet will involve intense work and also persistence. If you are all set to invest enough time and also efforts into it, there are a variety of tips for acquiring a lot more cash flow from the net.I am getting $10000 or even higher month to month through this gig.Here’s the shortcut to make profits although the others are longer term ideas to make money >>>>> OUOURL.COM/4rgz

  • Have you constantly profited a ton of money without selling anything as well as without exercising any existing direct selling form of task and never having to make an investment anything at all. I wanted to discuss a venture wherein all specialty tools will likely be handovered to you and consequently it truly is a very simple or even not hard gig. Its not necessary to set up your personal domains and stuff like that., everything is definitely made available to you without cost. Everyone will definitely log in your site therefore you are able to get paid for that. Its as simple as that. Now I am making huge amounts of funds online out of this job really like $20 thousand a month or maybe more and if you also genuinely wish to take home money like this so therefore follow these specific effortless guidelines by visiting this web-site >>>>> URL4.UK/idRdt