Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 3948  / 2 Years ago, sat, january 15, 2022, 4:00:29

I'm running Ubuntu Server 12.04, and trying to get all Shell command logged.
I'm trying with rsyslog that there by default.
I added "*.* /var/log/everything.log" in rsyslog.conf and 50-default.conf, but I'm only getting few entries(login,logout, service stop/start) and would like to have everything ls, cd [path], [Wrong command].



Do I have to modify something in rsyslog or setting any other application to verbose.



Thx
SP


More From » log

 Answers
6

As an alternative to using bash_history, to capture every command entered in the shell by yourself and save it to file you could use something like the trap command in a script or function and place that code in .bashrc.



Fortunately, exactly the script you want was provided by Richard Hansen a while ago in this answer, and his script copies every command entered into bash and sends them (with a timestamp) to a file called .command_log by default. Once you have placed his script into your .bashrc and have launched terminal, Richard's script writes the commands to .command_log as soon as they are executed, unlike the bash_history feature, which only writes to the file after the terminal is closed.



Richard's script will record your commands like this in .command_log (although you will be using different commands to me):



2012-10-02T18:02:11+0100 /dev/pts/2 gksudo truecrypt
2012-10-02T21:52:03+0100 /dev/pts/2 xrandr -s 1280x1024
2012-10-03T00:16:52+0100 /dev/pts/2 mount
2012-10-03T00:17:12+0100 /dev/pts/2 udisks --unmount /dev/sdb1
2012-10-03T00:17:46+0100 /dev/pts/2 udisks --detach /dev/sdb


I have been using it for a while and find that Richard's script is very useful; you can even grep the .command_log and search for anything you want:



grep -i udisks .command_log 


So, I think this is probably what you want if you need to record every single thing typed into bash; I find it incredibly useful.


[#35017] Saturday, January 15, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rowbris

Total Points: 419
Total Questions: 122
Total Answers: 101

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;