简体   繁体   English

Linux(Ubuntu) Terminal-如何查看以前的页面不再可见

[英]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. 然后,选中Unlimited ,或设置所需的行数。 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 某些终端应用程序(gnome-terminal)允许您增加回滚缓冲区大小

pipe output to a file: 管道输出到文件:

command > file.log

pipe your command to less: 将命令管道减少:

command | less

tail log and pipe to grep to reduce output 尾部日志和管道grep以减少输出

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

If you want to scroll line by line, you can use 如果要逐行滚动,可以使用

Control+Shift+Up/Down Arrows. 控制+ Shift +向上/向下箭头。

Try using the screen command, and set its scrollback buffer to a larger size. 尝试使用screen命令,并将其回滚缓冲区设置为更大的大小。

screen has many other benefits and wonderful features. screen还有许多其他好处和精彩功能。

If all you're doing is looking at a log, you could alternately use a pager such as less 如果你正在做的只是查看日志,你可以交替使用诸如less的寻呼机

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

yourcommand | tee output.txt

If you are using gnome-term (the default), then you can change your settings. 如果您使用的是gnome-term(默认值),则可以更改设置。 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. 基本上支持@ zerick的解决方案,但如果你在gnome-terminal你可以修改它的配置。 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.所有答案都是如何使新终端 windows(或当前终端)开始以某种方式运行。 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.要回答这个问题,每个终端 session 都应该有自己的“历史”文件(不要与命令历史混淆),其中包含与显示的标准输入/标准输出相关的所有内容。 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.当您关闭窗口/结束 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 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) (那是如果 session 当前仍然打开,而不是关闭终端窗口)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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