Custom Search

Ubuntu tail log tutorial

Sometimes we need to view just a part of a big Ubuntu file. For example. when we are going to locate error or check system activity in Ubuntu system log. Ubuntu command that can be used to check for latest log generated by the system is tail command. The tail command by default displays last 10 lines in the file.

Here is part of tail manual page that describes the usage:

NAME
       tail - output the last part of files

SYNOPSIS
       tail [OPTION]... [FILE]...

DESCRIPTION
       Print  the  last 10 lines of each FILE to standard output.
       With more than one FILE, precede each with a header giving
       the file name.  With no FILE, or when FILE is -,
       read standard input.

If we are going to check latest system log, we can issue tail /var/log/messages command. See an example below:

luzar@ubuntu:/var/log$ tail /var/log/syslog
Feb 11 09:30:01 ubuntu console-kit-daemon[5150]: CRITICAL: 
cannot initialize libpolkit
Feb 11 09:30:01 ubuntu /USR/SBIN/CRON[5213]: (root) CMD ([ -x 
/usr/sbin/update-motd ] && /usr/sbin/update-motd 2>/dev/null)
Feb 11 09:32:12 ubuntu dhclient: DHCPREQUEST of 172.16.153.129 on eth0 
to 172.16.153.254 port 67
Feb 11 09:32:12 ubuntu dhclient: DHCPACK of 172.16.153.129 from 172.16.153.254
Feb 11 09:32:12 ubuntu dhclient: bound to 172.16.153.129 -- renewal in 899 seconds.
Feb 11 09:40:01 ubuntu console-kit-daemon[5260]: CRITICAL: 
cannot initialize libpolkit
Feb 11 09:40:01 ubuntu /USR/SBIN/CRON[5323]: (root) CMD ([ -x 
/usr/sbin/update-motd ] && /usr/sbin/update-motd 2>/dev/null)
Feb 11 09:47:11 ubuntu dhclient: DHCPREQUEST of 172.16.153.129 on eth0 
to 172.16.153.254 port 67
Feb 11 09:47:11 ubuntu dhclient: DHCPACK of 172.16.153.129 from 172.16.153.254
Feb 11 09:47:11 ubuntu dhclient: bound to 172.16.153.129 -- renewal in 883 seconds.
luzar@ubuntu:/var/log$

We can use tail to check latest messages generated by system log, we can issue tail /var/log/messages command. See an example below:

luzar@ubuntu:~$ tail /var/log/messages
Feb 11 09:06:04 ubuntu kernel: [    8.354312] lp0: using parport0 
(interrupt-driven).
Feb 11 09:06:04 ubuntu kernel: [    8.427308] Adding 489940k swap on /dev/sda5.
Priority:-1 extents:1 across:489940k
Feb 11 09:06:04 ubuntu kernel: [    8.462337] EXT3 FS on sda1, internal journal
Feb 11 09:06:04 ubuntu kernel: [    8.707586] ip_tables: (C) 2000-2006 
Netfilter Core Team
Feb 11 09:06:04 ubuntu kernel: [    8.746051] eth0: link up
Feb 11 09:06:04 ubuntu kernel: [   13.362431] NET: Registered protocol family 17
Feb 11 09:06:04 ubuntu kernel: [   20.601093] NET: Registered protocol family 10
Feb 11 09:06:04 ubuntu kernel: [   20.611324] lo: Disabled Privacy Extensions
Feb 11 09:26:09 ubuntu -- MARK --
Feb 11 09:46:09 ubuntu -- MARK --
luzar@ubuntu:~$

Remember that tail command is very useful command when troubleshooting error during Ubuntu server configuration.

No comments:

Post a Comment

Please keep comment relevant and strictly no spam will be tolerated. Thank you.