History command, Linux
From RZWiki
A command shell built-in function available on Linux platforms; used to modify, display or delete the command history list.
Contents |
Usage Syntax
history [options]
Common options include;
- number - only display the specified number of most recent command history list entries
- -c - clear the entire command history list
- -d line_number - delete the command history list entry specified by line_number
- -a filename - append the command history list for the current session only to the file specified by filename
- -r filename - read the contents of the specified filename and use them as the command history list
Usage Examples
history 10 - display the 10 most recent entries in the command history list
history -d 132 - delete the command history list entry with line number 132
history -c - delete the entire command history list
Usage Notes
Most shells support a number of command history related Shell Expansion Characters
Use font color=limegreen!n/font to insert the text of the command history list line number n at the command line
Use font color=dodgerblue[CTRL]/font+font color=limegreenR/font to search the command history list
- BASH will auto-complete the first command matching the text you enter. Repeat font color=dodgerblue[CTRL]/font+font color=limegreenR/font to display the next command history match
- Use font color=lightslategray[RETURN]/font to execute the command or, to cancel: font color=darkcyan[ESC]/font or font color=dodgerblue[CTRL]/font+font color=limegreenC/font
See our Linux CLI Masterclass for more information on information on effective and efficient use of the command line.
Related Files
The default bash history file location is here: ~/.bash_history
Security Considerations
Using any commands or associated options or parameters that include password presents a security risk as any users with read access to your command history list file ~/.bash_history will be able obtain the password. Either;
- Avoid specifying a password with the command (if the program can prompt instead)
- Clear the entire history list using history -c
- Remove the specific command from the history list using history -d line_number
Linux Usage Notes
With most Linux or Unix commands;
- Non root users may need to prefix commands with the sudo command, for example: sudo chmod 644 *
- Brief help can be displayed using the -h or --help parameter, for example: chmod --help
- A full command manual can be displayed using the man command followed by the command name, for example: man chmod
- Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
- Version information can normally be display using the -v, -V or --version parameter, for example: chmod --version. However, this paramater is also frequently used to display verbose output.
noinclude/noinclude
Command Equivalents
The Cisco command equivalent is the show history command
The Windows PowerShell command equivalent has the same name: history command, Windows PowerShell
The Extreme command equivalent has the same name: history command, Extreme
The Nortel command equivalent has the same name: history command, Nortel
The Lexmark Print Server history command displays the current firmware revision, not a command history.
Related Articles
See our Linux CLI Masterclass for more information on information on effective and efficient use of the command line.
Information on other Linux commands
Information on F5 BigIP commands
Information on Cisco commands
Information on Vyatta commands
Information on Extreme commands
Information on Zebra commands
Information on Secure Platform commands
Information on Blue Coat SGOS commands
Information on Nokia IPSO commands
(replacing the # with an @) |






