Ubuntu – How to view the `.bash_history` file via command line

bashcommand linehistory

I want to view the contents of my .bash_history file but don't know how to get there via the command line.

Best Answer

If you want to access the actual file itself, just use your favorite text editor (I use emacs but you can use pluma of gedit or vimor whatever):

emacs ~/.bash_history

That is the default location if your history file. If you don't find anything there, you may have changed the history file's name. This is stored in the $HISTFILE variable, so print it out to check its current value:

echo $HISTFILE

If, instead of the file, you just want to see your history, you can run history as @minerz029 suggested. The history command with no options just prints the contents of your $HISTFILE followed by the commands executed in the current shell that have not yet been written to that file, with line numbers.