Linux history command details

Source: Internet
Author: User

 

Display command execution time

Linux shell has the history function, that is, it records the commands that have been executed, but by default, it does not display the command execution time, command execution time, and history, but it is not displayed. Now let's see how to display the execution time. Simple: add the HISTTIMEFORMAT environment variable to/home/$ USER/. bashrc. The details are as follows:

After the addition is complete, execute source. bashrc to make it take effect. At this time, you can execute history to find that the time has been displayed. As follows:

Clear history

In order not to trace the execution of commands, history-c can be used to clear historical commands. For example:

History-c clears itself and its previously executed commands.

Modify retained entries in history

Sometimes we think that the history command entries retained by history are too small. If you want to save more, you can directly modify the history configuration and add the following content to. bashrc:

HISTFILESIZE = 2000 (default value: 1000)

Common history commands

History n lists the n commands that have been executed recently.

! Number: run the history command of the specified Number. There is no space between the Number and the exclamation point.

!! Repeat the previous command

List the last N historical commands

Run the command with the specified number

Repeat the previous command

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.