Let the Linux history command show the execution time of the command, which machine executes the command

Source: Internet
Author: User


1. Add the following section at the end of the/etc/profile:
user_ip= ' who-u am I 2>/dev/null| awk ' {print $NF} ' |sed-e ' s/[()]//g ' export histtimeformat= ' [%F%t][' WhoAmI '][${user_ip}] "
2. Source/etc/profile
3. Execute whatever command you want,
4. Executive history, see effect: 311 [2013-08-28 14:39:20][root][192.168.80.1] History 312 [2013-08-28 14:39:43][root][192.168.80.1] D F-h 313 [2013-08-28 14:39:45][root][192.168.80.1] df-g 314 [2013-08-28 14:39:47][root][192.168.80.1] History 315 [ 2013-08-28 14:40:01][root][192.168.80.1] ifconfig [2013-08-28 14:44:53][root][192.168.80.1] init 6 317 [2013-08-28 14:46:56][root][192.168.80.1] SDFSDFSD 318 [2013-08-28 14:46:58][root][192.168.80.1] LS 319 [2013-08-28 14:47:02][roo t][192.168.80.1] hostory [2013-08-28 14:47:04][root][192.168.80.1] History 321 [2013-08-28 14:48:35][root][192.168 .80.1] Cat/etc/profile 322 [2013-08-28 14:54:32][root][192.168.80.1] History
Note: 1 and 2 must be done before you can see the effect of the history. If you want to see the history of 1 months ago, and then did not do 1 and 2, this situation is not to see the desired effect.

Let the Linux history command show the execution time of the command, which machine executes the 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.