Real-time monitoring of Linux Server user action commands

Source: Internet
Author: User

Append in/etc/profile

Export History_file=/var/log/history/userhistory.logreadonly prompt_command= ' {date ' +%y-%m-%d%T ##### $ (Who am I |awk " {print \$1\ "\" \$2\ "\" \ $NF} ") # # # # (Id|awk" {print \$1} ") # # # # (History 1 | {read x cmd; echo "$cmd";}) ";} >> $HISTORY _file '



Reread Source/etc/profile can take effect.

Mkdir-p/var/log/history/

Touch/var/log/history/userhistory.log

New configuration file in/etc/logrotate.d/userhistory

/etc/loratate.d/userhistory content is as follows

/var/log/history/userhistory.log {Weekly Notifempty prerotate/usr/bin/chattr-a/var/log/his Tory/userhistory.log Endscript Postrotate/bin/chmod 002/var/log/history/userhistory.log/usr /bin/chattr +a/var/log/history/userhistory.log Endscript}


This article is from the "New Lei blog" blog, make sure to keep this source http://helloeveryone.blog.51cto.com/6171143/1529723

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.