Bash history commands

A few commands to mess with your shell command line history:

If you want to: Then you just type Notes
View the last N commands you ran$ history N
Erase all shell history$ rm ~/.bash_historyYour commands are normally stored in a hidden file called .bash_history, in your home directory.
Turn off the logging of history for your terminal session$ unset HISTFILE
Run a command without it being recorded in the historyAdd a space BEFORE the command.

Log commands in a different file$ HISTFILE= path_to_file/name_of_file
Record the time of a command$ HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S"

No comments:

Post a Comment