tail (output the last part of files)

This command is the opposite of →head. It outputs the “tail” of a file, that is, its last 10 lines. If you want to view a different number of lines, call tail like this:

tail -30 file

In this example I asked tail to output 30 lines. You can substitute any other number.

An option that is very commonly used with tail is -f (“follow”). Try entering this command:

sudo tail -f /var/log/syslog

tail will print out the last ten lines of /var/log/syslog and “follow” the file, that is, it will print out any lines that are added to the file. If you wait a while, you'll see how new entries to /var/log/syslog are output on the terminal. This form of the tail command is useful for getting a real-time view of logged messages.