How can you see the last 'n' lines of a file named 'filename'?

Prepare for the Linux Professional Institute Certification Level 1. Use flashcards and multiple choice questions, complete with hints and explanations. Enhance your understanding and get ready to ace the exam!

To view the last 'n' lines of a file named 'filename', using the command tail with the -n option is the correct approach. The tail command is designed to display the last part of files. When you specify the -n option followed by a number, tail will output that specific number of lines from the end of the file. This command is particularly useful for monitoring log files or any file where the most recent entries are of primary interest.

For example, running tail -n 10 filename will show you the last 10 lines of the specified file. This makes it an essential tool for quick file inspections.

The other options do not correctly achieve this result. The head command, for instance, displays the first 'n' lines of a file instead of the last. The last command is typically used to show the last logins of users and does not work on regular files in this manner. The show command is not a standard command in Linux for reading files; therefore, it won't provide any output in this context.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy