history
ShellBeginner In simulator In real LinuxShow command history
Name: history
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
history is a bash builtin listing the commands you have run, numbered. History lives in memory and is written to ~/.bash_history when the shell exits; HISTSIZE and HISTFILESIZE set how much is kept.
Use !number, !! and Ctrl+R to rerun earlier commands quickly.
Syntax
history [N] | history -cCommon options
| N | Show only the last N entries |
| -c | Clear the history |
| -d OFFSET | Delete entry OFFSET |
| -w | Write the history to ~/.bash_history now (normally on exit) |
| !N | (bash) Re-run command number N |
| !! | Run the last command again (as in sudo !!) |
| !string | Run the latest command starting with string |
| Ctrl+R | Search back through the history (Ctrl+R again for older ones) |