history
To get history show time
1 2 |
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc source ~/.bashrc |
history -a will append your current session history to the content of the history file.
history -w will replace the content of the history file with your current session history.
To remove line number from history, run
1 |
history | sed 's|[0-9]\+\s\+||' |
Or
1 |
history | cut -d' ' -f5-40 |
Log everything
To log everything, edit
1 |
vi /etc/bash.bashrc |
Add
1 |
test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'script' || (script -f $HOME/$(date +"%d-%b-%y_%H-%M-%S")_shell.log) |
Or manually start logging with
1 |
script -f $HOME/session.log |