Как Ubuntu запоминает историю процессов?

Недавно я заметил две вещи в своем Ubuntu-13.10 (32-битном) и хотел бы очиститься.

Сценарий-1:

Одной из функциональных возможностей терминала является то, что вы можете получать предыдущие команды, используя клавишу со стрелкой «ВВЕРХ». Но когда я использовал стрелку вверх, он показывал мне все команды, которые я использую с последних дней. С тех пор я много раз выключал свой ноутбук. (Я не сплю, я каждый раз полностью выключаю)

Вопрос:

Как Ubuntu запоминает все эти команды? Сохраняет ли это состояния в каком-то кеше или что-то в этом роде?

Сценарий-2:

Подобное было в случае с файлами PDF. Когда я открыл PDF-файл в одной из встроенных «программ для чтения документов», он сразу начал со страницы, где я последний раз читал.

Вопрос:

Снова возник тот же вопрос: «Как Ubuntu узнал, что я оставил на этой конкретной странице?»

Это может быть проблема с кешем, но я думаю, кеш в ubuntu полностью очищается при каждом выключении.

Спасибо,

1
задан 3 February 2014 в 10:11

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 - где он может быть ...

Для текущего сеанса на компьютере временное хранилище (подобно открытию сжатых файлов в Archive Manager) выполняется в /tmp и очищается при завершении работы. Более постоянное хранилище (например, миниатюры файлов для File Broweser) хранится в ~/.cache, а скрытые файлы в домашнем каталоге ~/.*.

0
ответ дан 3 February 2014 в 10:11

Другие вопросы по тегам:

Похожие вопросы: