Linux for Developers
/Beginner
history
Definition
A command that prints a numbered list of the previously executed commands stored in the user's shell history file.
Explain Like I'm New
The 'What did I just type 5 minutes ago?' command. It remembers everything you've typed so you don't have to memorize complex commands.
Real World Example
You ran a massive, complex Docker command yesterday but forgot it. You type `history | grep docker`. The terminal searches your past commands and prints out the exact command you used, saving you 20 minutes of Googling.
Common Use Cases
- •Recalling complex commands
- •Security auditing (seeing what a user typed)
Interview Questions
basic
- How can you re-run a specific command from your history without retyping it (e.g., command number 105)?
intermediate
- If you type a password directly into a command (like `mysql -u root -p1234`), is it saved in the history file?