Log in Go to the main page Page Discussion History Go to the file list Go to the site toolbox Bookmark and Share

History command, Linux

From RZWiki


Image:linux-logo-large.png

A command shell built-in function available on Linux platforms; used to modify, display or delete the command history list.

Contents

Image:Vm-power-on-medium.png 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

Image:Vm-power-on-medium.png 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

Image:accessories-text-editor-v2-medium.png 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.

Image:Folder-medium.png Related Files

The default bash history file location is here: ~/.bash_history

Image:Security-high-medium.png 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

Image:accessories-text-editor-v2-medium.png 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

Image:object-flip-horizontal-medium.png Command Equivalents

The Cisco command equivalent is the show history command Image:Cisco-logo-small.png

The Windows PowerShell command equivalent has the same name: history command, Windows PowerShell Image:Preferences-system-windows-small.png

The Extreme command equivalent has the same name: history command, Extreme Image:Extreme-logo-small.png

The Nortel command equivalent has the same name: history command, Nortel Image:Nortel-logo-small.png

The Lexmark Print Server history command displays the current firmware revision, not a command history.

Image:icemon-medium.png 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 Image:linux-logo-small.png

Information on F5 BigIP commands Image:F5-logo-small.png

Information on Cisco commands Image:Cisco-logo-small.png

Information on Vyatta commands Image:Vyatta-logo-small.png

Information on Extreme commands Image:Extreme-logo-small.png

Information on Zebra commands

Information on Secure Platform commands

Information on Blue Coat SGOS commands

Information on Nokia IPSO commands


Image:internet-group-chat-small.png We really do appreciate all feedback so please do send your comments, suggestions or corrections to sjiveson#routerzone.eu
(replacing the # with an @)


Site Toolbox:

Personal tools
This page was last modified on 21 September 2009, at 22:00. - This page has been accessed 33 times. - Disclaimers - About RZWiki
Powered by MediaWiki