1

Does anyone have any recommendation of an CLI tool for ubuntu that works as a log viewer?

I know you can do like sudo cat /var/log/mail.log to read that specific log file.

But maybe there is a tool that has a cute cli interface for browsing all logs that say exist inside the /var/log folder and it's subfolders ? :)

2

Yes, there is such a tool

Read man journalctl

In my ~/.bashrc, in order to save typing, I have

alias jc=journalctl

I use jc -u postfix.service to look at my mailer logs.

jc -h, jc --fields, jc --field=FIELD will show what you can ask journalctl about on YOUR system.

I also use "journalctl parenthesis". In ~/.bashrc:

# tsjou "18-11-01 01:55:28" for journalctl --since
alias tsjou="date '+%y-%m-%d %H:%M:%S'"

# record beginning for journalctl
alias jstart="JSTART_TIME=\"\$(tsjou)\""
#show journal since `jstart`
alias jend="journalctl --since=\"\$JSTART_TIME\""

Then, just BEFORE I "do it" (connect the device or other action that creates log entries):

jstart

Then, I do the thing, wait a couple of seconds for the logs to "settle", and

jend

will show me everything that been logged since jstart

jc /usr/sbin/NetworkManager to see what's up with networking.

One of my systems has been crashing (turned out to be power distribution). I use jc -b -1 -e to look at the end of the logs of the previous boot, in the hope of finding a commonality among the crashes. The lack of such a commonality was what led me to power.

jc --follow will follow the journal in near real time.

Looking through my bash history, I find I've used:

jc -b  _PID=1452 _PID=2772 _PID=2773
jc --since="14:25"
jc --since="2017-11-27 14:24:00" --until="2017-11-27 14:26:00" 
jc --since="-30 minutes"
jc --since="$(tsjou --date="09:30")"
jc --since="$(tsjou --date="march 28 09:55:00")"
  • 1
    @Kulfy updated, with exmples and hints – waltinator Jul 6 at 17:35
  • @luxwarp: Did my updated answer help? If so, please click the checkmark to accept my answer, so I'll gain reputatiion points and eventually Rule the World. – waltinator Jul 9 at 17:57
  • @waitinator Oh! Thank you so much! You got accepted ;) – Luxwarp Jul 10 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.