Linux uses the script command to save user operation records

  
                

Linux systems are very useful in the office environment. For example, in the command line that comes with the Linux system, you can record the behavior of employees using the computer. This article will introduce Linux's method of saving user operation records using script commands.

Encounter problems: The company has added operation and maintenance administrators. To ensure the security of the server and to confirm the problem when problems occur, it is necessary to record the behavior track of each server registrant.

Solving the problem: The linux script command is so powerful. Meet our needs. Script records the terminal session.

Operation steps:

I am a centos6.3 system, comes with a script command, if not, you need to install it 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

The operation performed after the user logs in will be recorded to /mnt/log/script/*. In the log (the directory itself is defined according to the server directory), we can view it by more or vi.

I am here to record the user ID is greater than 1000, you can log back in to the user, operate some commands, view the generated file. Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved