Where my bash command history is stored
In Category Bash
The bash shell stores all your command history in a file of your home directory. Typically it will be stored in ~/.bash_history. This is a global history of all bash terminals which are open. The bash shell appends all commands executed in a terminal just before closing the terminal.
The history command can be used to view the active history at bash shell prompt.
[neo@techpulp ~]# history 1 ls 2 vi test.c 3 gcc test.c -o test 4 ./test 5 pwd 6 history [neo@techpulp ~]#
The number followed by NOT symbol (!) can be used to repeat a specific command. The following example shows how to repeat the command number 5 which is pwd.
[neo@techpulp ~]# !5 pwd /home/neo [neo@techpulp ~]#
Similarly the NOT symbol (!) followed by any string can be used to execute the recent command in history that starts with the given string. The given string can be partial and doesn’t have to be complete name of the command.
[neo@techpulp ~]# !pw pwd /home/neo [neo@techpulp ~]#
At the bash shell prompt, one can use UP and DOWN arrow keys to traverse through the history of commands.
The command “history -c” can be used to clear the bash history.
[neo@techpulp ~]# history -c [neo@techpulp ~]# history [neo@techpulp ~]#
If you don’t want bash to add your command history after you logout, “unset HISTFILE” can be executed.
[neo@techpulp ~]# echo $HISTFILE /home/neo/.bash_history [neo@techpulp ~]# unset HISTFILE [neo@techpulp ~]#
Recent Comments