Windows doskey /history equivalent in Linux
Shows previously run commands. Linux keeps a much longer history than Windows.
doskey /history
history
history
history
Overview
What this command does
On Windows, "doskey /history" is used to view command history. On Linux, the closest practical mapping shown here is "history". Shows previously run commands. Linux keeps a much longer history than Windows. This reference is grouped under Terminal & Shell Scripting → Terminal.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows doskey /history maps to history for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read Linux command-line basics.
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
Debian/Ubuntu, Fedora and Arch all use "history" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| 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