Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging terminal commands

Is there a way to log(/var/log) commands executed by users in the Unix shell?

like image 714
BlueGene Avatar asked Nov 19 '25 22:11

BlueGene


1 Answers

Assuming you're doing this for security purposes, take a look at process accounting. You didn't say which UNIX variant you're on, but for Linux, take a look at http://www.gnu.org/software/acct/ Beware that you will generate a lot of data as process accounting writes data about every command run system wide (its a kernel feature). Your distro probably has the utilities already; in Debian check the 'acct' package.

If you're just trying to log what you did so you can go back and look at it later, script (as in the other answer) or screen (with -L) will provide a better solution. However, they will not work for security auditing because its trivial to bypass them: just run a shell script. Also, line editing makes a royal mess of the files. Curses apps (like, say, a text editor) are even worse.

Also, if you force your users through e.g., script, you may wind up capturing information (e.g., email messages) which it may be illegal for you to intercept.

like image 199
derobert Avatar answered Nov 21 '25 17:11

derobert