linux--record the IP information of each user after login, there are other operation information

Source: Internet
Author: User

#Linux--Log The IP information of each user after login, and other operation information, append

vim/etc/profileps1= "' WhoAmI ' @ ' hostname ': ' [$PWD] '

(Linux system prompt is defined with system variable PS1)

History

(Who-u am I will show the system logged in users and landing from which IP landed in, here after filtering on the value of a login incoming IP)

user_ip= ' who-u am I 2>/dev/null| awk ' {print $NF} ' |sed-e ' s/[()]//g "if [" $USER _ip "=" "]thenuser_ip= ' hostname ' FIIF [! -d/tmp/ruige]thenmkdir/tmp/ruigechmod 777/tmp/ruigefiif [!-d/tmp/ruige/${logname}]thenmkdir/tmp/ruige/${logname} chmod 300/tmp/ruige/${logname}fiexport histsize=4096dt= ' date ' +%y:%m:%d%r ' export histfile= '/tmp/ruige/${logname}/ ${USER_IP} ruige. $DT "chmod 600/tmp/ruige/${logname}/*ruige* 2>/dev/null

This article is from the "A-B-C" blog, reproduced please contact the author!

linux--record the IP information of each user after login, there are other operation information

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.