with the bash history it’s a very useful but also a bit confusing thing X-D

whenever a bash terminal is exited, it saves the histoy to

cat ~/.bash_history

did the user know that with the super cool hotkey-shortcut: Ctrl+R then type a letter like “ssh” or “storagebox”

(reverse-i-search)`ssh': ssh user@192.168.123.123; # ssh into storagebox, keywords: this, that

with Ctrl+R it is possible to search the history + use the history like a set of stored commands (“aliases”), that can be reused or modified fast

put a #comment on what this command is for or even keywords

and make it even MORE convenient by searching for keywords

(heavy use of that feature using it all the time)

this is excellent, but what could be better: imho the ~/.bash_history should be written  (after every command?) and read more often

so the history is in sync on all bash terminal shells

this can be done manually

# append current history of current shell, needs to be done for all open shells

history -a

# reload history file in the bash where user wants to search latest typed commands

history -r

how to delete history:

on ALL open shells go

history -c
history -w

# then
echo "" > ~/.bash_history
killall bash

output history without line numbers

history | cut -c 8-

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin