Get the App
SLTechnology News&Howtos  ›  Servers  › 

Display and manipulate history commands using linux's history command

Shulou Source: shulou.com Published: 2022-06-02 13:49:13 10月03日 Update

This article will explain in detail about the use of linux history commands to display and manipulate historical commands. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The history command is used to display historical commands that the user has executed before, and can append and delete historical commands.

If you often use the Linux command, then using the history command can effectively improve your efficiency.

Syntax format: history [parameters] [directory]

Common parameters:

-an appends the history commands of the current shell session to the command history file The command history file is the configuration file that saves the history command-c clear the current history command list-d delete the command number specified in the history command list-n read the history command that was not read at the beginning of this Shell session from the command history file-r read the command history file to the current Shell history command memory buffer-s add the specified command to the command history memory buffer as a separate entry. Delete the last command in the command history memory buffer before adding-w writes the contents of the current shell history command memory buffer to the command history file

Reference example

Show the last 10 commands:

[root@linuxcool ~] # history 10

Write the login command to the history file:

[root@linuxcool] # history-w

Read the contents of the command history file into the current history memory of shell:

[root@linuxcool ~] # history-r

Appends the history commands of the current Shell session to the command history file:

[root@linuxcool] # history-a

Clear the list of current historical commands:

[root@linuxcool] # history-c on the use of linux history command display and manipulation history command is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Commands history files history files memory buffers buffers contents parameters more articles references good practical effective middle finger examples commonly used serial numbers efficiency Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS Xiaomi Apple Shulou Technology