Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With wich command can I get all the lines of a file in my terminal?

Tail and cat shows me only the last part of the file

share|improve this question
up vote 4 down vote accepted

If a file has too many lines to show in only one screen, you can pipe the output to less like so:

cat myfile.txt | less

This paginates cat's output, allowing you to navigate through the file using the arrow keys.

share|improve this answer
UUOC (useless use of cat) :) – izx May 18 '12 at 22:13
Huh. I'll be that much smarter tomorrow! Thanks for teaching me something I didn't know! :) – SirCharlo May 18 '12 at 22:30
This approach can be used with any command that prints text e.g. git status | less – topher Sep 12 '13 at 21:18

Depending on the size of the file, you can use tail (if there are only 10 lines) or cat to see the whole log file.

If you want to use a better file viewer for logs on the terminal, I would advise using less on a file.

For Example

sudo less /var/log/syslog

This will produce the log file on your terminal screen and you will be able to move around the log file without it passing you like cat.

Advanced less features

  • To make sure text will stay on the screen after exiting less (very useful if you don't have an interface):

sudo less -X /var/log/syslog

  • To ignore cases on searches through less:

sudo less -i /var/log/syslog

  • To display line numbers when opening a file with less:

sudo less -N /var/log/syslog

To learn more about less

man less


less --help

share|improve this answer

You actually can just use less without piping too

less myfile.txt

More works well too:

more myfile.txt

The main differences between the two are that more only allows you to go down in a document, whereas less lets you go up and down. The benefit that more has is that is also keeps the information in the terminal when you exit it, which can be very helpful in certain situations.

share|improve this answer

You can use less command for viewing files with rich extended navigation besides tail and cat, that only output file content to console.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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