Bash history
(Redirected from Bash History)
Jump to navigation
Jump to search
Bash command history feature allows to recall, edit and rerun previous commands. Also allows commands to be saved using the history -a
command[1][2].
Variables to control Bash History:
- HISTSIZE (
echo $HISTSIZE
) - HISTFILE[3]: The default value is
~/.bash_history
- HISTFILESIZE
- HISTTIMEFORMAT [4]
Contents
Usage[edit]
- Save every executed command to:
~/.bash_history
- Advanced examples:
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
[5]export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'
[6]- Sending history to syslog (needs recompiling source): Bash also support syslog capabilities at compiling time[7] but it is not enabled by default in most distributions: https://github.com/bminor/bash/blob/d233b485e83c3a784b803fb894280773f16f2deb/config-top.h
Activities[edit]
- Install https://github.com/ohmybash bash customization
- Review output from
history
command
Other terms[edit]
See also[edit]
acct
- Bash history:
history[ -a | -c | -r ]
,history --help
,~/.bash_history
,HISTFILE, HISTSIZE, HISTTIMEFORMAT, HSTR
Bash [ -c ]
,alias
,&&
, Bash history, Autocompletion,set
,unset
,export
,.bash_aliases, .bashrc and .bash profile
,PS1
,echo
,brace expansion
, Function,shopt
,trap
,set -e
,source
,PATH
,complete
,disown
,.hushlogin
,.bashrc
,builtin
,eval
,set
,$PATH
,$HOME
,TZ
,.profile
,-e, -i
,Builtin (Bash)
,mapfile
,~
, return (Bash), for, until,declare, dirname, basename, functions.sh
, Bash arithmetic expansion,shift, bash --rcfile, readonly, $1, $@
, Bash versions
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.
Source: https://en.wikiversity.org/wiki/Bash_programming/Bash_History
- ↑ https://unix.stackexchange.com/questions/145250/where-is-bashs-history-stored
- ↑ https://www.gnu.org/software/bash/manual/bash.html#Bash-History-Builtins
- ↑ <https://www.gnu.org/software/bash/manual/bash.html#index-HISTFILE
- ↑ https://www.gnu.org/software/bash/manual/bash.html#index-HISTTIMEFORMAT
- ↑ https://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/
- ↑ https://gist.github.com/NISH1001/bf2b713418b4e2ede8e6a7373b42c4c1
- ↑ https://unix.stackexchange.com/questions/457107/sending-bash-history-to-syslog
Advertising: