开发者

Linux(Ubuntu) Terminal-how to view previous pages not visible anymore

开发者 https://www.devze.com 2023-01-06 14:18 出处:网络
When you scroll up, say to see a log, the first portion of it will not be visible since the terminal only supports a limited no. of lines. So if you want to scroll up and be able to see everyt开发者_J

When you scroll up, say to see a log, the first portion of it will not be visible since the terminal only supports a limited no. of lines. So if you want to scroll up and be able to see everyt开发者_JS百科hing, at least a few pages up, how do you do it?


Use Shift+Page Up and Shift+Page Down.


Piping the output to a pager like the following is a better choice:

command | less 

command | more


You can enable unlimited scroll back (or a huge amount if you want).

To do this, go to

File → Profile preferences → Scrolling [tab]

Then, check Unlimited, or set the number of lines desired. And of course, it only applies to the next typed lines.


Some tricks I use-

some terminal applications (gnome-terminal) allow you to increase the scroll-back buffer size

pipe output to a file:

command > file.log

pipe your command to less:

command | less

tail log and pipe to grep to reduce output

tail -f example.log | grep 'search text'


An alternative to screen is using tee to copy all output to a file while still printing it on the terminal:

yourcommand | tee output.txt


Try using the screen command, and set its scrollback buffer to a larger size.

screen has many other benefits and wonderful features.

If all you're doing is looking at a log, you could alternately use a pager such as less


If you want to scroll line by line, you can use

Control+Shift+Up/Down Arrows.


If you are using gnome-term (the default), then you can change your settings. Either set the no. of lines to unlimited, or to a much larger buffer size than the default.


Essentially seconding to @zerick's solution but if you're on gnome-terminal you can modify its config. See this.


If you are in tmux (can create multiple terminal sessions in a single terminal session, highly recommended), you can easily use your normal navigation keys to scroll around after you do Ctrl-b then [, for more details let's take a look at: How do I scroll in tmux?


None of these answer the original question. All answers are how to make new terminal windows (or current one) start behaving a certain way. The question is about how to see whats already scrolled away.

To answer this, each terminal session should have it's own "history" file (not to be confused with what command history is) containing all the stuff that relates to stdin/stdout displayed. I could be wrong but this may be different depending on the terminal emulator you use. Some just trash it when you close the window/ end the session.

I am trying to get this figured out myself so here is the more direct answer in a different thread.

https://unix.stackexchange.com/questions/145050/what-exactly-is-scrollback-and-scrollback-buffer

From what this tells me, I suspect best advice you can get is, for whatever terminal emulator you use, look for where it stores the scrollback buffer and that might be your only hope. It's what I am going to try right now. (and that is IF the session is currently still open, not closed terminal windows)

0

精彩评论

暂无评论...
验证码 换一张
取 消