Link to home
Start Free TrialLog in
Avatar of apunkabollywood
apunkabollywoodFlag for United States of America

asked on

I want to record all the commands ran by any user(or root) in Linux

I need this mechanism via bash script or any RHEL Package.
Avatar of Sean Fitzpatrick
Sean Fitzpatrick
Flag of United States of America image

ex. given from FreeBSD
cat /usr/home/%username/.bash_history >> %username%history.log

You'll need to update the path for the user depending on what kernel version you are using.
Also you will need to run the cat as a root user or with sudo depending on kernel, so that you can read other user's bash_history files.
Easy way to figure out where the history files are located is my doing a 'locate history', if you don't have locate installed you can install mlocate, then run an updatedb; after you have done that, retry running the 'locate history' command.

Also: Is this something that you want to do once? or constantly update? If you want to constantly update the file, use the >> if you want to rewrite the file every time use > instead.
Avatar of Jan Bacher
Turn on auditing and require sudo (logging the commands) for all privileged commands even if you don't require knowing the root password.
Like _jesper_ said, I think auditing is the way to go.
Avatar of apunkabollywood

ASKER

I found the solutions !

https://www.experts-exchange.com/OS/Linux/Distributions/A_683-Auditing-user-sessions.html

One more thing I want to send/save the files generated from script command to an oracle database. How i can achieve that ?
One more thing, how I can get rid of garbage created by the interactive commands like vi from script command.
What do you mean by "garbage"?  Can you give an example?
snoopy from epel does it. How you pump syslog to oracle is another question. Mostly syslog servers have semimaintained oracle modules that you need to fix before using.
Hi All,

@jesper - from garbage i mean ASCII code generated in the files while recording shell via script command.

@gheist - Thanks . snoopy is great tool, I will look on it and I want these logs piped to oracle.

I have a blog , do you think it can work what i need ?

http://blog.ronnyegner-consulting.de/2009/11/11/logging-syslog-and-database-audit-messages-to-an-oracle-database-with-rsyslog/

Thanks All !
ASKER CERTIFIED SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you