Let the linux history command display the command execution time, on which machine the command is executed, linuxhistory

Source: Internet
Author: User

Let the linux history command display the command execution time, on which machine the command is executed, linuxhistory

1. Add the following parts at the end of/etc/profile:
USER_IP = 'Who-u am I 2>/dev/null | awk '{print $ NF}' | sed-e's/[()] // g'' export HISTTIMEFORMAT = "[% F % T] ['whoam'] [$ {USER_IP}]"
2. source/etc/profile
3. Whatever command you want to execute,
4. execute history to check the effect: 311 [14:39:20] [root] [192.168.80.1] history 312 [14:39:43] [root] [192.168.80.1] df-h 313 [14:39:45] [root] [192.168.80.1] df-g 314 [14:39:47] [root] [192.168.80.1] history 315 [14:40:01] [root] [192.168.80.1] ifconfig 316 [14:44:53] [root] [192.168.80.1] init 6 317 [] 14:46:56] [root] [192.168.80.1] sdfsdfsd 318 [14:46:58] [root] [192.168.80.1] ls 319 [14:47:02] [root] [192.168.80.1] hostory 320 [14:47:04] [root] [192.168.80.1] history 321 [14:48:35] [root] [192.168.80.1] cat/etc/profile 322 [14:54:32] [root] [192.168.80.1] history
Note: The effects of history can be viewed only after the commands 1 and 2 are executed. If you want to view the history of a month ago, and haven't executed 1 and 2 at that time, you can't see the desired effect.

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.