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:
-
I am a centos6.3 system and have built-in script commands. if not, you need to install them manually.
-
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.