Geody Labs


# Main Index: Debian Linux Magic Spells Cheat Sheet (one liners, how to, tips and tricks)

# Shell History

List of all commands entered in the shell (history):
jed ~/.bash_history # edit history file manually
cat ~/.bash_history # show all commands in history (up to last session)
less ~/.bash_history # navigate in history
history | grep "apt-get install \|apt install " # Search for last packages installed manually
cat ~/.bash_history | tr "\|\;" "\n" | sed -e "s/^ //g" | cut -f 1 -d " " | sort -n | uniq -c | sort -nr | head -n 10 # show the 10 most used commands in history (including piped commands)
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n 10 # show the 10 most used commands in history (first command only). NOTE: if dates are enabled in history, it will show days when more commands were issued
history | awk '{CMD[$4]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n 10 # show the 10 most used commands in history (first command only) if dates are enabled
history # show all commands in history together with their offset
history -d OFFSET # delete the specified history entry
history -c # clear the whole history file
!!:p # show last executed command
!-1:p # show last executed command
!-2:p # show second last executed command
!TEXT:p # show last command starting with TEXT (for example, ls)
!! # repeat (execute again) last executed command
!-1 # repeat (execute again) last executed command
!-2 # repeat (execute again) second last executed command
!TEXT:p # repeat (execute again) last command starting with TEXT (for example, ls)
export HISTTIMEFORMAT="%F %T  " # Set history date format (normally by default date and time of executed commands is not preserved in history)
echo $HISTTIMEFORMAT # See history date format




Please DONATE to support the development of Free and Open Source Software (PayPal, Credit Card, Bitcoin, Ether)

Page issued on 25-Sep-2022 06:05 GMT
Copyright (c) 2022 Geody - Legal notices: copyright, privacy policy, disclaimer