CentOS records user behavior tracks

Source: Internet
Author: User
Problem: The company has added an O & M Administrator. to ensure server security and confirm the problem when a problem occurs, you need to record the behavior track of each server login. Solution: The linuxscript command has such powerful functions. Meet our needs. Script records terminal sessions. Operation procedure: I am a centos6.3 system with script commands. if not, you need to install them manually. Vim/

Problem: The company has added an O & M Administrator. to ensure server security and confirm the problem when a problem occurs, you need to record the behavior track of each server login.

Solution: The linux script command has such powerful functions. Meet our needs. Script records terminal sessions.

Procedure:

  1. I am a centos6.3 system and have built-in script commands. if not, you need to install them manually.

  2. Vim/etc/profile

Add at the end:

If [$ UID-ge 1000]; then

Exec/usr/bin/script-t 2>/mnt/log/script/$ USER-$ UID-'date + % Y % m % d % H % M '. date-a-f-q/mnt/log/script/$ USER-$ UID-'date + % Y % m % d % H % M '. log

Fi

In this way, the operations performed after the user logs on will be recorded in/mnt/log/script/*. log (the directory is defined by the server directory). we can view the operations through more or vi.

Here I will record all operations with a user ID greater than 1000. you can log on to the user again and run some commands to view the generated files.

 

In addition, the/mnt/log/script Directory requires the write permission of other users;

Chmod 743/mnt/log/script

 

As you can see, the corresponding user logon will generate a file with the suffix log and date respectively. Logs Record the operation. you can use the date file to play back the operation. Play back through scriptreplay
Note: the "time File" and the "command file" should not be reversed.
All operation records of users are recorded. In addition, the playback function is similar to video recording, making it easy to find problems.

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.