The history command
The history command lists the commands you have typed, numbered…
The history command lists the commands you have typed, numbered, so you can find and run them again.
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.
Usage
history [-c]
List the commands you have run. Lists the commands you have run, numbered. The up and down arrow keys step through the same list.
How to use history
See your recent commands
The up and down arrow keys step through the same list.
ls && pwd && historya.tmp app.log archive b.tmp backup.sh beach.jpg bin build cat.jpg data.csv diary.txt draft.txt fruit.txt images names.txt notes.txt old old-site old.txt part1.txt part2.txt photos projects report.txt scores.txt screen1.png screen2.png server.log shared.txt shopping-new.txt shopping.txt website website-2025.tar.gz
/home/learner
1 ls && pwd && history
Search it
ls && history | grep lsa.tmp app.log archive b.tmp backup.sh beach.jpg bin build cat.jpg data.csv diary.txt draft.txt fruit.txt images names.txt notes.txt old old-site old.txt part1.txt part2.txt photos projects report.txt scores.txt screen1.png screen2.png server.log shared.txt shopping-new.txt shopping.txt website website-2025.tar.gz
1 ls && history | grep ls
Options
| -c | clear the list |
|---|
More examples
history1 history
Questions about history
How do I run a command from history again?
Press the up arrow, or type !number (as in !42) to run that entry, or !! to run the last command. Ctrl+R searches as you type.
How do I clear my history?
history -c clears the list for this terminal.
Related commands
Every everyday command on one page, to print or keep open: the Linux commands cheat sheet.