1. List Your Bash History
Bash keeps track of every command entered in a session. To display your entire session history, use:2. Search Commands with grep
To filter history for specific keywords, pipe the output togrep. For example, to find all sudo invocations:
For comprehensive details on
grep, see the GNU grep Manual.3. Locate the .bash_history File
Bash writes your commands to~/.bash_history when you log out. To view hidden files in your home directory:
~/.bash_history in any text editor or display it with:
Commands executed in your current session only appear in
~/.bash_history after you log out.4. Navigate History Interactively
Bash lets you recall and edit past commands right in the prompt. Use these keystrokes:
When you find the desired entry, press Enter to re-execute or edit it inline.