Linux History Command Details

Source: Internet
Author: User

The history command is used to display a specified number of command commands, to read the directory from the historical command file to the history command buffer, and to write the directory in the history command buffer to the command file.

When this command is used alone, only the history command is displayed, and on the command line, you can use the symbol to ! execute the history command of the specified ordinal.

The history command is stored in memory and is automatically saved or read when you exit or log in to the shell. In memory, the history command can only store 1000 historical commands, which are controlled by environment variables HISTSIZE

History Common Command parameters
-C: Clears the current History command;-A: Writes the command in the history command to the history command file "/root/.bash_history";-r: Reads the command from the history command file into the current History command buffer;-W: Writes the current History command buffer command to the history command file "/ Root/.bash_history ";
N: Print the most recent n history command
#  History will list all the historical commands that bash has saved, and they are numbered, and we can run a specific history using the "exclamation mark Number" method
!+ Letter: Call up the most recent command that starts with this letter!!: command that represents the most recently used operation!+ Number: A few commands to bring up the history-number: Bring up the last few commands
Common Command Display

History command Show Execution Time "show ordinal and command by default"

# Temporary effect
[Email protected] ~]# export histtimeformat= '%F%T ' [[email protected] ~]# echo $HISTTIMEFORMAT [[email protected] ~]# hist Ory 2
# Permanent Effect
[Email protected] ~]# vim/root/.bash_history
        --->  add Export histtimeformat= '%F%T '
Source/root/.bashrc    

View the number of caches for history

# view variables directly [[email protected] ~]# echo $HISTSIZE      # View file contents [[Email protected] ~]# cat/etc/profile | grep ' histsize ' Note: HIST Size=0, indicating that history is disabled

See the last 10 commands

[[Email protected] ~]# history 10

Use the last command you used

[[email protected] ~]#!!

Use the NUM Bar command

[Email protected] ~]#!994

Show a specific command that was recently used

[Email protected] ~]#!echo

Get the arguments for the previous command

[email protected] ~]# ls sun.txt [[email protected] ~]# cat!$

Linux History Command Details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.