72

I was running scripts overnight from the command line (inside Screen on a Linux EC2 instance) and some errors that I was not tracking occurred. I want to "scroll up" or view more of the history in Screen, but I cannot seem to find any commands that will work.

I need to see the onscreen output "further up" than I can on my current screen. CTRL + a is supposed to put me into scroll mode inside Screen, but it's not working.

6
  • history | less, more? Or you are asking how to keep more history?
    – khachik
    Jun 28 '11 at 19:47
  • history will keep only commands have been fired in shell. He is more asking about logging sort of stuff
    – Rahul
    Jun 28 '11 at 19:49
  • <Shift> + <PgUp> is the only option. And it has some limit as well (at most last 500 lines, I guess).
    – ssapkota
    Jun 28 '11 at 19:51
  • I need to see the onscreen output "further up" than I can on my current screen. CTRL + a is supposed to put me into scroll mode inside Screen, but it's not working for me. Jun 28 '11 at 19:52
  • 3
    Just Ctrl-a is screen's escape. The whole key sequence to enter scrollback mode would be Ctrl-a [, as opyate says. Ctrl-a ESC also works for me, I don't remember which one is standard / commonly used.
    – ninjalj
    Jun 28 '11 at 20:01
35

When you start screen you can specify the size of the scrollback buffer with -h, so you can increase it from the default of 100 lines. However, with a currently running screen, once the data has left the buffer, it is gone.

4
  • 7
    This is just plain wrong. The answer by @opyate does provide a solution Jul 4 '17 at 15:23
  • 7
    @nirvana-msu Using ^a to enter scrollback mode allows you to page up the scrollback buffer. If data is already gone from the scrollback buffer, it is gone. You can increase the size of that bufer at startup. What exactly about my answer do you think is incorrect? I talk about increasing the size of the scrollback buffer, opyate gives details on how to use it. Jul 4 '17 at 19:02
  • 3
    Well, ok, though the question wasn't really about extending scroll buffer. The author wanted to view more history than what's normally shown in console, and you can view more history using Ctrl+a+[. Your answer just makes it seem like it's not possible, which is misleading. Jul 4 '17 at 19:08
  • This is not working on a mac. The other answers are not working neither.
    – bomben
    Oct 4 '19 at 7:20
102

Assuming you haven't overriden your escape sequence, you can press Ctrl-a [ to go into scrollback mode, then use the usual Page-UP/Page-DOWN or Ctrl-b/Ctrl-f to go up and down.

From the Gentoo wiki on Screen usage

7
  • 16
    and ESC to exit scrollback mode, IIRC
    – ninjalj
    Jun 28 '11 at 19:58
  • now the gentoo wiki is: wiki.gentoo.org/wiki/Screen
    – Rmatt
    Nov 8 '14 at 16:11
  • also see this post for how to (sort of) get scrolling with the mouse working. The post name says its for tmux but it also covers screen
    – JonnyRaa
    Feb 25 '15 at 14:54
  • 6
    Ctrl+A,Esc also enters the copy/scrollback mode. Dec 13 '17 at 9:44
  • 1
    Thank you this answer and the comment by @SergeStroobandt saved me 10 hours of work. May 13 at 6:31
13

I need to see the onscreen output "further up" than I can on my current screen. CTRL + a is supposed to put me into scroll mode inside Screen, but it's not working.

In complement to the other answers, I would point out that you may add in your ~/.screenrc file:

defscrollback 100000
termcapinfo xterm ti@:te@

where:

  • defscrollback 100000: set the default number of scrollback lines to 100000
  • termcapinfo xterm ti@:te@: allow terminal scrolling in either xterm or PuTTY. (screen FAQ; PuTTY FAQ)
3
  • Not working on a Mac. None of the answers work here. I still can just see the size of the Terminal window. Further up is just the screen command and the stuff I did before screen. I also tried screen -h, same result. Any ideas?
    – bomben
    Oct 4 '19 at 7:24
  • @Ben sorry no idea, I only tried on Ubuntu. Oct 4 '19 at 7:25
  • 2
    Ah, it does work with control + a and then ESC and then I am able to scroll inside the text with the cursor. What does not work is scrolling with the mouse using the Mac Terminal sliders on the side. Thanks!
    – bomben
    Oct 4 '19 at 7:34
8

You can also change the scrollback history size in a running screen with the sequence CTRL-a : (enter screen command-line mode), then scrollback 10000 if you want 10k lines of history buffer. The change applies immediately.

Be careful of memory usage if you use many screens with very long buffers.

However, like @William Pursell said, with a currently running screen, once the data has left the buffer, it is gone.

7

You can also run your commands in the script command which will log the output to disk. Or you can: command 2>&1 | tee /tmp/cmd.out to log the output for future investigation in you wanted a (practically) infinite sized output history.

1
  • this is what I ended up using for my task. Works great. Thanks. Jun 28 '11 at 21:59
0

Depending on what terminal program you are using, you can usually change the Scrolling Buffer under Settings. I know for xterm you have to enable Scrolling first, then you can set the buffer to infinite.

Your best bet however for logging scripts would be to Re-direct the standard output to a file:

ScriptName >> OutputFile.txt

Doing it this way you can scroll and search freely as well as keep a record (i.e. in case your computer crashes).

EDIT: This is close to the piping solution above, however redirecting standard input can be useful in other instances as well:

grep linux stackoverflow.txt > linuxquestions.txt

or

cat linuxquestions.txt | grep buffersize > bufferquestions.txt
2
  • Do note that screen(1) doesn't allow terminal scrolling. That's both one of its main features and one of its main drawbacks.
    – sarnold
    Jun 28 '11 at 20:59
  • @sarnold It's possible to allow terminal scrolling, see superuser.com/a/1336554/116475 Jul 4 '18 at 19:30
0

Using a macOS Terminal I was not able to use the sliders at the side to see text history.

I was able to scroll with the cursor inside the text using and after I hit CRTL + a and then ESC.

And I had to add this to ~/.screenrc to enable mouse scrolling from inside the window (still not with the sliders):

termcapinfo xterm* ti@:te@
0

Ctrl + A, followed by Esc

also enters the copy/scrollback mode of screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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