Learn how the shell history remembers commands, how to search and reuse them, and how to control what gets recorded. 22.03.2026 | reading time: 3 min The `history` builtin keeps a numbered list of previously typed shell commands so he can recall, search and replay work without retyping; this article shows concrete examples and safe configuration tips to turn that list into a real productivity tool. Recover a dropped command Start by running a few commands and then inspect history; the example below shows commands, the `history` output with numbers, and how to reuse entries with history expansion: ```bash ls /etc cat /etc/hosts ssh admin@192.0.2.10 # show recent history history | tail -n 5 100 ls /etc 101 cat /etc/hosts 102 ssh admin@192.0.2.10 # reuse commands !102 # repeats the ssh command !! # repeats the previous command !101:p # prints the command 101 without executing it ``` Control, search and edit the list Use `history | grep` to find past commands, `history -d OFFSET` to delete an entry, `history -c` to clear the session, and `history -w` / `-r` to write or read the history file; configure `HISTSIZE`, `HISTFILE` and `HISTIGNORE` to tune retention, set `HISTTIMEFORMAT` to add timestamps, and use `fc` to open a previous command in an editor for complex fixes, while remembering to avoid recording secrets by using leading spaces with `HISTCONTROL=ignorespace` or by unsetting `HISTFILE` in sensitive sessions. When history becomes a toolchain Pair `history` with `grep`, `awk` or `sed` to extract patterns and reconstruct sequences, use `fc` for in-place command edits, and capture full interactive sessions with `script` when replayability or auditing is required; readline shortcuts (Ctrl-r) provide quick incremental search directly from the prompt. A compact wrap-up History turns repetition into velocity and investigation into evidence; master its expansions, variables and safety knobs and he will waste far less time retyping and more time solving real problems, and for deeper exam-focused study consider intensive preparation at bitsandbytes.academy for certifications like CompTIA Linux+ or LPIC-1. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting