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.
apunkabollywoodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sean FitzpatrickSr Lab Systems EngineerCommented:
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.
0
Jan SpringerCommented:
Turn on auditing and require sudo (logging the commands) for all privileged commands even if you don't require knowing the root password.
0
Zephyr ICTCloud ArchitectCommented:
Like _jesper_ said, I think auditing is the way to go.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

apunkabollywoodAuthor Commented:
I found the solutions !

http://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 ?
0
apunkabollywoodAuthor Commented:
One more thing, how I can get rid of garbage created by the interactive commands like vi from script command.
0
Jan SpringerCommented:
What do you mean by "garbage"?  Can you give an example?
0
gheistCommented:
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.
0
apunkabollywoodAuthor Commented:
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 !
0
gheistCommented:
Most likely you need to compile syslog-ng yourself to include oracle support, but yes, it is possible:
http://www.balabit.com/sites/default/files/documents/syslog-ng-ose-3.3-guides/en/syslog-ng-ose-v3.3-guide-admin-en/html/configuring_sql_oracle.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
apunkabollywoodAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.