简体   繁体   中英

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

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 everything, at least a few pages up, how do you do it?

使用Shift + Page UpShift + 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'

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

Control+Shift+Up/Down Arrows.

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

屏幕的替代方法是使用tee将所有输出复制到文件,同时仍将其打印在终端上:

yourcommand | tee output.txt

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 .

如果您在tmux中(可以在单个终端会话中创建多个终端会话,强烈推荐),您可以轻松使用常规导航键在Ctrl - b后滚动[ b ] ,有关详细信息,请查看: 如何在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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM