Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I noticed two things in my Ubuntu-13.10(32-bit) and would like to get cleared.


One of the functionality of terminal is that you can get previous commands by using "UP" arrow key. But when I used up arrow, it was showing me all commands that I am using since last many days. I have switched off my laptop many times since then. (I am not hibernating it, I completely shut it down each time)


How is Ubuntu remembering all this commands ? Does it saves the states in some kind of cache or something ??


Similar was the case with pdf files. When I opened a pdf in one of the in-built "Document Reader", it directly started from the page where I last left reading.


Again the same question arose and that is "How did Ubuntu came to know that I left on that particular page?"

It may be the cache issue but I guess cache in ubuntu is cleared completely at every shutdown.


share|improve this question
Two things ? :D – Wilf Feb 2 '14 at 10:49
:D :D .. ya I mean, I noticed two things in my Ubuntu. ;) – v1h5 Feb 2 '14 at 18:08
It says one thing at the top :) – Wilf Feb 2 '14 at 18:29
edited the question. ;) :D – v1h5 Feb 3 '14 at 6:11
up vote 3 down vote accepted

Scenario 1

The commands are simply saved as a list to the ~/.bash_history file. this is a hidden file (Begins with .), in your home directory (~). You can view the history of commands run by running history, which is similar to cat -n ~/.bash_history, except the latter does not include commands from the current running terminal session, as those are saved when the terminal closes. Here is the manual page for 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.

Scenario 2

Dunno where that would be - Document Viewer - evince - has config files in ~/.config/evince, but nothing seems useful there. There is a local cache directory - ~/.cache - where it could be...

For the current session on the computer, temporary storage (Like opening compressed files in Archive Manager) is done in /tmp, and is cleared on shutdown. More permanent storage (e.g. file thumbnails for the File Broweser) is stored in ~/.cache, and hidden files in the home directory ~/.*.

share|improve this answer
evince stores its metadata in gvfs, so it is stored in the ~/.local/share/gvfs-metadata/ directory in one of the binary files. Unfortunately this makes accessing those data pretty uncomfortable for us. See like here – falconer Feb 2 '14 at 13:20
@falconer - 1st comment - yeah, binary files are weird - 2nd comment - Oh S.... – Wilf Feb 2 '14 at 15:55
@wilf - wonderful ! I just got to know that I have executed 2000 commands in one month. ;-) – v1h5 Feb 2 '14 at 18:05
@v1h5 - I probably only do around 600... :D – Wilf Feb 2 '14 at 18:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.