Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Bash Command History in linux

Shulou Source: shulou.com Published: 2022-06-01 05:16:19 11月15日 Update

Editor to share with you the history of Bash commands in linux example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

Command history

Bash has the function of automatically recording the history of commands, and commands executed by users will be automatically recorded in a hidden file such as. Bash_history in their home directory when logging out. There are many ways to view the history of these commands, including by opening the file directly, flipping the history up or down through the up and down keys of the keyboard, and viewing the history through the history command, all of which have record numbers. The amount of information that can be recorded in the command history is determined by the HISTSIZE variable. CentOS 6.3 defines HISTSIZE=1000 by default through the / etc/profile file, that is, it can record up to 1000 commands that have been used recently. When the 1001 command is executed, the * command will be overwritten. Executing the history-c command can clear all history records.

Those who record the history of the command can not only view the history, but also directly call the history to execute the command again when needed:

1)。 The arrow keys flip through the history command, find the appropriate command and then enter directly to execute it.

2)。 Enter! string invokes command history (string is the keyword). For example,! vim will call * * commands that begin with vim. Or through! n to accurately locate the history, for example! 242 will directly call the command history of the 242 record and execution.

3)。 Open the search function through the Ctrl+r shortcut key, and then enter the keyword to search for relevant commands in the command history, and enter to complete the operation. If no suitable command is found, press ESC to exit the search.

The above is all the content of the article "sample Analysis of the History of Bash commands in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Commands history search can be passed through files articles examples analysis up and down keywords keywords content functions input appropriate not much that is information again variables Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux NVidia macOS Shulou Tech Info