I'm installing a package and get a load of errors and need to be able to read through all the error messages that come up. Unfortunately the terminal will only display a finite number of lines. How do I go about viewing previous lines or changing the maximum number of lines that can be displayed?

  • 2
    See if your terminal has something to increase or decrease scrollback lines.
    – user25656
    Dec 4, 2013 at 12:04

8 Answers 8


Like David Purdue suggests, I myself too. I like to have unlimited scrolling.


You can also enable the scrollbar if you want; but I prefer it disabled and use Shift + Page Up and Shift + Page Down keys to change the output frames.

  • Where to do this in Ubuntu 15.04? the profile preferences are not visible anywhere.
    – MycrofD
    Jul 8, 2015 at 13:09
  • 1
    sorry @MycrofD can't say about that, have not tried 1504.. you should check the script command and see if it fits to your needs. This was one of the adviced ones on my simillar post for TTY console terminal askubuntu.com/questions/487133/…
    – rusty
    Jul 14, 2015 at 7:52
  • I tried both checking "unlimited" and setting the scrolling to 4096 lines. Neither works; the terminal insists on showing only 30 lines. I'm well aware of redirection, and Vim seems to do the right thing, but sometimes I just want to scroll. What could I be missing? Oct 31, 2016 at 16:53
  • 1
    Is there a way to do it in the terminal? I want to do it on a Docker container and creating new files is unsupported on the Docker image I'm using so being able to scroll up farther instead of dumping the terminal output to a file would be beneficial. Feb 5, 2019 at 17:13
  • 1
    Note that in modern versions of Ubuntu, it's under Unnamed -> Scrolling -> uncheck "Limit scrollback to:". (Replace "Unnamed" with the name of your profile if you changed it.)
    – Matias
    Jan 16, 2022 at 15:03

Use less:

your_command | less 

Your Enter key will take you down.

Also, press q to exit.

  • 1
    do you mean "yourcommand | less" ?
    – MycrofD
    Jul 8, 2015 at 13:11
  • Sadly, this likely won't work for OP's "load of errors," because those errors are likely going to stderr, not stdout, and | redirects only stdout. (I believe your_command 2>&1 | less will work in that case; see unix.stackexchange.com/questions/3514/… for more discussion.) Jan 21, 2023 at 14:33

If you are using the standard Terminal program on a Desktop version of Ubuntu...

  1. Choose Edit -> Profile Preferences from the terminal windows global menu.

  2. Choose the Scrolling tab

  3. Set Scrollback to the desired number of lines (or check the Unlimited box).

Then you can use the scrollbar at the side of the terminal to scroll back through the lengthy command output.

  • 2
    Where is Edit -> Profile ?
    – gfan
    Sep 11, 2018 at 9:19
  • It is in the menu bar for the Terminal program. This usually appears at the top of the screen when Terminal has focus, but you may have to move your mouse to the top of the screen for it to appear. Dec 17, 2018 at 10:34

You could start your command in a script session every action an command output would be saved without interfering with the execution unless |less or >file that forbid to have any interaction with the command.

$ script /tmp/command.out
Script started, file is /tmp/command.out
$ the_command
$ exit 
Script done, file is /tmp/command.out
$ less /tmp/command.out

If you want to see the data and also run it to a file, use tee, e.g,

spark-shell | tee tmp.out

(spark-shell is just the example interactive program that you might want to capture output from.)

This will allow you to type commands in response to output from the program, but also capture the output to a file.


I recommend you to use output redirection. Type:

user@host:~# command >filename

Then you can read the file with a text editor for example less and browser through the output:

user@host:~# less filename
  • The question is quite specific about not wanting to do that and instead increasing the scroll buffer size Aug 19, 2021 at 7:20
  • @PeterKionga-Kamau This question has 7 answers, 2 of which suggest increasing scroll buffer size and the other 5 are basically equivalent to my answer. The question is about reading previous lines and the above is one possible solution for that. Sometimes there exist multiple solutions to a problem. Collecting them is one purpose of this site.
    – chaos
    Aug 19, 2021 at 8:49

You could use | to output your command into more. For example, if I wanted to read an entire text file that wouldn't fit on screen using cat, I would use:

cat /home/abcd/Downloads/fileName.txt | more  

You can press enter to scroll down one line at a time, and q to exit. Press g to start over.

Hope this could be useful to you.


Ubuntu 22.04

The default number of scroll back lines in Ubuntu 22.04 is 10000. You can change this to any number up to 2147483647 or disable it altogether. Both can be done either from the GUI or from the command line.

From the GUI

Open Terminal -> Settings (the hamburger button) -> Preference -> Profiles -> Unnamed -> Scrolling. There you will see Limit scrollback to. You can either disable it altogether or change the number of lines you want to scroll back like this:

Preferences - Profile Unnamed

From Command Line

The same thing can be done from the command line, using gsettings. Read more about how this works in this post: How to change gnome-terminal scrollback lines from command line.

Enable unlimited scrollback:

gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')/ scrollback-unlimited true

Limit scrollback to 250,000 lines:

gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')/ scrollback-lines 250000

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .