How to view the log of all commands? How to view the log of all commands? unix unix

How to view the log of all commands?


You can do this with cat $HISTFILE.

Bash by default stores the last 500 commands in a history file, most likely called ~/.bash_history. This file is in the variable $HISTFILE (and the size is in $HISTFILESIZE). You can get the path to the history file with echo $HISTFILE.


If you are still in the shell a quick way to see your recent session command history is the command:

$ history

Very handy for the scenario mentioned in the question, i.e. a colleague has typed some commands quickly in your session and you want to go back and have a closer look at them.


history 1

This will display all entries in History starting at line 1.