Windows
Linux
Terminal & Shell Scripting
Terminal
Windows doskey /history equivalent in Linux
Shows previously run commands. Linux keeps a much longer history than Windows.
Windows
→
doskey /history
Linux equivalents
history
history
history
Overview
What this command does
Shows previously run commands. Linux keeps a much longer history than Windows.
Migration tip: Press Ctrl+R to search your command history interactively — type part of a past command and it appears. This is one of the most powerful terminal productivity shortcuts.
Practical tasks
Common use cases
View command history
Shows previously run commands. Linux keeps a much longer history than Windows.
history
Show all recent commands with numbers
history 20
Show last 20 commands
!42
Re-run command number 42 from history
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
history
history 20
history | grep apt
!42
Walkthrough
Examples with explanations
# Windows: doskey /history
history # show all history
history 20 # last 20 commands
history | grep apt # find past apt commands
# Re-run a command by number:
42 sudo apt update
!42 # runs command 42 again
# Best shortcut:
Ctrl + R # then type to search history
Reference
Common options and variations
| Command or option | Use |
|---|---|
history | Show all recent commands with numbers |
history 20 | Show last 20 commands |
!42 | Re-run command number 42 from history |
!! | Re-run the last command |
!string | Re-run last command starting with 'string' |
Ctrl+R | Interactive reverse history search |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | history |
Same command on this distribution. |
| Fedora | same command | history |
Same command on this distribution. |
| Arch | same command | history |
Same command on this distribution. |
Keep learning