051. history commands and execution time

Source: Internet
Author: User

Because Linux's default history record only saves the command content, there is no specific time, I can only find the user's logon and exit time to give them a time range.

Therefore, it is necessary to optimize the record function of history commands. The recommended parameters are as follows:

Edit/etc/profile and add the following configuration information:


# Set the file size for saving History commands


Export HISTFILESIZE = 1000000000


# Number of historical commands saved


Export HISTSIZE = 1000000


# Real-Time History commands. By default, records are recorded only after the user exits, which easily overwrites multiple users.


Export PROMPT_COMMAND = "history-"


# Record the execution time of each historical command


Export HISTTIMEFORMAT = "% Y-% m-% d _ % H: % M: % S"

Or: export HISTTIMEFORMAT = "% F % T 'whoam '"










Make changes take effect immediately:

# Source/etc/bashrc



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.