The history command shows the detail time

Source: Internet
Author: User

Article excerpt from:

http://blog.csdn.net/lixiaohuiok111/article/details/34428161

http://blog.csdn.net/lixiaohuiok111/article/details/34428161 first we give the OPT directory a write permission to sudo chmod a+w/opt then execute source/etc/ Profile and then exit the machine, when you re-enter the/opt/history below there will be a file generated by the admin.History
And then we'll change the permissions back to write scripts to use Ansible batch deployment to other machines
  • #!/bin/bash
    sudo chmod a+w/opt
    Cat <<eof>>/etc/profile
    #History
    User_ip=\ ' who-u am I 2>/dev/null| awk ' {print \ $NF} ' |sed-e ' s/[()]//g ' \ '
    if ["\ $USER _ip" = ""]
    Then
    User_ip=\ ' hostname\ '
    Fi
    if [!-d/opt/history]
    then
    mkdir/opt/history
    chmod 777/opt/< Span class= "Highlight" >history
    fi
    if [!-d/opt/history/\$ {LOGNAME}]
    then
    mkdir/opt/history/\${logname}
    chmod 300/opt/history/\${logname}
    fi
    export histsize= 4096
    export histtimeformat= "%F%T $USER _ip:\ ' whoami\ '"
    export histfile= "/opt/history/\${logname}. history "
    chmod 600/opt/history/* history* 2>/dev/null
    eof
    source/etc/profile
    sudo chmod o-w/opt

#History
user_ip= ' who-u am I 2>/dev/null| awk ' {print $NF} ' |sed-e ' s/[()]//g "
If ["$USER _ip" = ""]
Then
User_ip= ' hostname '
Fi
if [!-d/opt/History]
Then
mkdir/opt/History
chmod 777/opt/History
Fi
if [!-d/opt/History/${logname}]
Then
mkdir/opt/History/${logname}
chmod 300/opt/History/${logname}
Fi
Export histsize=4096
Export histtimeformat= "%F%T $USER _ip: ' WhoAmI '"
Export histfile= "/opt/history/${logname}. History
chmod 600/opt/history/*history* 2>/dev/null

The history command shows the detail time

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.