The commands are not visible because Bash saves history to the .bash_history file only after the shell quits, and this happens very rarely with Guake. There is a simple workaround to make Bash append the history (instead of overwriting the file) after every command
shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
If no commands can be run using ↑ or ↓ that indicates that your history file is empty or you have no read-permissions. Check that.
Maybe you run the commands as another user. If so do:
su otheruser
history 10
and look at the output.
If you change $HISTFILESIZE
the changes will be overwritten, whenever you invoke an other shell. To prevent that you should change that variable in your .bashrc
. Also you should set the variable $HISTSIZE
to a larger value.
Generally usefull tips using histories:
Ctrl+R does a reverse search of your history for you. Alt+. pastes the last argument of the last command into your prompt at cursor position.
Also the bang (!
) operator will repeat commands for you in terminal (if it's just about saving you some typing. Example:
confus@confusion:~$ echo "bang + letters will repeat the last command starting with these letters."
bang + letters will repeat the last command starting with these letters.
confus@confusion:~$ clear
confus@confusion:~$ !ech
bang + letters will repeat the last command starting with these letters.
All those histroy related things are stored in the home directory of any user in a file called .bash_history
. You can look them up by using the history
-command. Her is a small tutorial on howto use history.
confus@confus:~$ history 4 #will print last 4 commands
1848 ls
1849 clear
1850 vi /home/confus/.local/share/applications/nautilus-home.desktop
1851 history 4
Another very usefull thing is to create a .inputrc
file in your home directory with the following content:
"\e\e[C": forward-word
"\e\e[D": backward-word
"\e[A": history-search-backward
"\e[B": history-search-forward
This way you can use the ↑ or ↓ to complete commands you started to type from history. E.g. when you type a rather lenghty command such as rsync -a -v --human-readable --prune-empty-dirs -e 'ssh -i .ssh/id_rsa' --include="*/" --exclude="snapshot_*" --exclude="restart.*" /scratch/ x@cluster1:/home/x/runs/
and want to run it a second time you can just type rsy
and then ↑ an it will complete to the last command that started with rsy. Another press of the uparrow will complete to the second-last and so on. I don't know why this isn't the default.
Best Answer
When you open a bash terminal it loads the content of
~/.bash_history
and builds the active shell's history (in the RAM), adding every command executed in that shell to it – and only to it, not to the file.Only when you close a bash terminal its history is appended to your
~/.bash_history
file.Options of
history
:Options for
~/.bashrc
fileIf you want to change this behaviour so that the temporary history is saved to
~/.bash_history
directly after executing a command, add this line:If you additionally want every terminal to automatically load the
~/.bash_history
file after every command execution, add this line instead:If you want to exclude certain commands (e.g. everything beginning with
sudo
andcat
) from being saved, add this line: