To keep Bash commands available in later interactive terminal sessions, configure Bash to append history and set retention limits in the startup files your shells actually read. For most interactive terminals, add the settings below to ~/.bashrc.
Configure Bash history in ~/.bashrc
Open ~/.bashrc in a text editor and add these lines:
# Append this shell's history instead of overwriting the history file.
shopt -s histappend
# Example limits; choose values appropriate for your system.
HISTSIZE=10000
HISTFILESIZE=20000
# Optional: store and display history timestamps.
HISTTIMEFORMAT='%F %T '
histappend is the key setting when you use multiple shells: it makes Bash append the current shell’s history to the history file on exit rather than overwrite that file. Without it, one shell exiting can replace entries saved by another. Bash reads the file named by HISTFILE at startup; its default is ~/.bash_history. On exit, Bash writes the last HISTSIZE entries from the current history list. GNU Bash Reference Manual: Bash History Facilities.
Choose retention limits
HISTSIZE limits the number of commands kept in the current shell’s in-memory history list. HISTFILESIZE limits the number of lines retained in the history file. The values shown above are examples, not universal recommendations. Bash documents a default HISTSIZE of 500; after startup files are read, the default for HISTFILESIZE is set to HISTSIZE. GNU Bash Reference Manual: Bash Variables.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- Used Book in Good Condition
Optionally save timestamps
A nonempty HISTTIMEFORMAT makes Bash display timestamps with history entries and store timestamp information in the history file so it can persist between sessions. The format above displays date and time as year-month-day and 24-hour time.
Make sure your interactive shells read the settings
Bash startup files depend on how the shell starts. An interactive, non-login shell reads ~/.bashrc. An interactive login shell reads /etc/profile, then the first readable file among ~/.bash_profile, ~/.bash_login, and ~/.profile. Many ~/.bash_profile files source ~/.bashrc, but do not assume yours does. GNU Bash Reference Manual: Bash Startup Files.
- Check which profile file exists and is read by your login shell.
- If it does not source
~/.bashrc, either add the settings to that profile file or configure it to source~/.bashrc. - Use a new interactive terminal shell after editing so the startup settings take effect.
This setup is for interactive terminal shells. Non-interactive Bash scripts use BASH_ENV if it is set, and Bash has different startup behavior when invoked as sh or in POSIX mode; those cases do not necessarily read ~/.bashrc.
Check that history settings loaded and persist
In a new interactive Bash session, inspect the option, limits, and history-file path:
shopt -p histappend
echo "$HISTSIZE $HISTFILESIZE $HISTFILE"
history | tail
shopt -p histappend should report shopt -s histappend. The second command prints the active limits and file path; the final command shows recent entries. To verify persistence across sessions, run a harmless test command, exit normally, open another interactive Bash session, and check whether the command appears in history.
Troubleshoot missing or disappearing entries
One session removes another session’s entries
Confirm histappend is enabled in every relevant interactive shell. If a shell starts without the setting, it can overwrite the shared history file when it exits. GNU Bash Reference Manual: Bash History Facilities.
Rank #4
Nothing is being saved
Check that HISTFILE is set to a nonempty path and that the file is writable. Bash does not save history when HISTFILE is unset or null, or when the file cannot be written.
Older entries disappear
Review both limits: HISTSIZE constrains the current shell’s list, while HISTFILESIZE constrains the saved file. In particular, HISTFILESIZE=0 truncates the file to zero; negative or non-numeric values inhibit truncation. GNU Bash Reference Manual: Bash Variables.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
Some commands never appear
Check whether HISTCONTROL or HISTIGNORE is filtering them. ignorespace omits commands that begin with a space, ignoredups omits consecutive duplicate commands, and patterns in HISTIGNORE can exclude matching lines. GNU Bash Reference Manual: Bash Variables.
Keep secrets out of shell history
Bash history is a convenience, not a secure store for credentials. Avoid typing passwords, tokens, or other secrets directly into commands that may be recorded. Filtering settings can suppress selected commands, but they should not be treated as a reliable security boundary.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

