historyNumbered list of commands from this shell session and the history file.
The shell built-in that lists, searches and re-runs previous commands, and manages the history file.
historyNumbered list of commands from this shell session and the history file.
history <n>The last n commands.
Example
history 20history | grep <text>Searches past commands.
Example
history | grep sshCtrl-RReverse incremental search: type part of a command and press Ctrl-R again for older matches.
HISTTIMEFORMAT="%F %T " historyShows when each command was run (bash records times only if this was set when they ran).
!!Repeats the last command — sudo !! reruns it as root.
!<n>Runs command number n.
Example
!42!<prefix>Runs the most recent command starting with the text.
Example
!ssh!$The last argument of the previous command.
^<old>^<new>Reruns the previous command with a substitution.
Example
^tcp^udphistory -cClears the in-memory history of this session.
history -d <n>Deletes one entry.
Example
history -d 105history -aWrites this session’s commands to the history file now.
<command>With HISTCONTROL=ignorespace, a leading space keeps a command out of history.
Example
export API_KEY=secretSearches text for lines matching a pattern, with regular expressions, recursion and context.
Prints the last lines of files and follows them as they grow — the standard way to watch logs.
Reports free and used disk space on mounted file systems.
Estimates how much space files and directories use — find what is filling a disk.
Shows total, used and available memory and swap.
Prints the effective user name — the first question after landing a shell.