Learn to view the last lines of a file at the Linux command line.
Linux tail command summary with examples (3:53)
Videos can also be accessed from the YouTube Playlist.
Our twenty-eighth word, or command to memorize is
tail from our category
tail allows you to print the last
lines of a file.
Recall from the previous video we talked about
head, now we'll see that
tail command comes with a few
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
tail command has
12 options, where
had 6 and the argument is the file you'd like to
Like most commands, help is available with double-dash
The default is to print the last 10 lines, and the
-n option allows you to view more or
less than 10. And just like with
for bytes use
-c and not dash-b, as
you may think.
So why is
tail an important command?
Well, if you think about it, log files record system activity, and
tail is a way to monitor the most
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go, let's look at the last 10 lines, the default, of the file
from the previous video,
which was the help screen on the command
See how it prints right to the screen? Pretty easy huh?
Second, let's say we want to just look at this help information, so
let's do that on a
tail and the last 7
-n 7 the file
And we're all set.
And last, for the interesting stuff, let's act like a system
administrator and monitor a user's file. The
tail of this one, called
.bash_history, shows my last 10
Hmmm, interesting. ;)
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
Well, when you review the help page for
tail, read the
-s, or sleep, option as it automates
the review of log files, which is a good security precaution.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
More good times can be had at the YouTube Channel, subscribe here.
headcommand, hit Back.
apropos, click Next.