最近我注意到我的 Ubuntu-13.10(32 位)中有两件事,想将其清除。
场景 1:
终端的功能之一是,您可以使用“向上”箭头键获取以前的命令。但是当我使用向上箭头时,它会显示过去很多天以来我一直在使用的所有命令。从那时起,我已经多次关闭笔记本电脑。(我没有让它休眠,每次我都会完全关闭它)
问题:
Ubuntu 如何记住所有这些命令?它会将状态保存在某种缓存中吗?
场景 2:
pdf 文件的情况也类似。当我在内置的“文档阅读器”中打开 pdf 时,它直接从我上次阅读的页面开始。
问题:
同样的问题再次出现,那就是“Ubuntu 如何知道我离开了那个特定的页面?”
这可能是缓存问题,但我猜想每次关机时 ubuntu 中的缓存都会被完全清除。
谢谢,
答案1
场景 1
命令只是作为列表保存到~/.bash_history
文件中。这是一个隐藏文件(开始于.
),在你的主目录中(~
)。您可以通过运行来查看所运行命令的历史记录history
,它与 类似cat -n ~/.bash_history
,但后者不包括当前正在运行的终端会话中的命令,因为这些命令在终端关闭时会被保存。以下是 的手册页history
:
history [n]
history -c
history -d offset
history -anrw [filename]
history -p arg [arg ...]
history -s arg [arg ...]
With no options, display the command history list with line num‐
bers. Lines listed with a * have been modified. An argument of
n lists only the last n lines. If the shell variable HISTTIME‐
FORMAT is set and not null, it is used as a format string for
strftime(3) to display the time stamp associated with each dis‐
played history entry. No intervening blank is printed between
the formatted time stamp and the history line. If filename is
supplied, it is used as the name of the history file; if not,
the value of HISTFILE is used. Options, if supplied, have the
following meanings:
-c Clear the history list by deleting all the entries.
-d offset
Delete the history entry at position offset.
-a Append the ``new'' history lines (history lines entered
since the beginning of the current bash session) to the
history file.
-n Read the history lines not already read from the history
file into the current history list. These are lines
appended to the history file since the beginning of the
current bash session.
-r Read the contents of the history file and use them as the
current history.
-w Write the current history to the history file, overwrit‐
ing the history file's contents.
-p Perform history substitution on the following args and
display the result on the standard output. Does not
store the results in the history list. Each arg must be
quoted to disable normal history expansion.
-s Store the args in the history list as a single entry.
The last command in the history list is removed before
the args are added.
If the HISTTIMEFORMAT variable is set, the time stamp informa‐
tion associated with each history entry is written to the his‐
tory file, marked with the history comment character. When the
history file is read, lines beginning with the history comment
character followed immediately by a digit are interpreted as
timestamps for the previous history line. The return value is 0
unless an invalid option is encountered, an error occurs while
reading or writing the history file, an invalid offset is sup‐
plied as an argument to -d, or the history expansion supplied as
an argument to -p fails.
场景 2
不知道那会是哪里 - 文档查看器 - evince
- 中有配置文件~/.config/evince
,但那里似乎没什么用。有一个本地缓存目录 - ~/.cache
- 它可能在那里...
对于计算机上的当前会话,临时存储(就像在档案管理器中打开压缩文件一样)完成于/tmp
,并在关机时清除。更永久的存储(例如文件浏览器的文件缩略图)存储在~/.cache
和 主目录下的隐藏文件中~/.*
。