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.
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.
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.
Zephyr ICTCloud ArchitectCommented:
Like _jesper_ said, I think auditing is the way to go.
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 !


One more thing I want to send/save the files generated from script command to an oracle database. How i can achieve that ?
apunkabollywoodAuthor Commented:
One more thing, how I can get rid of garbage created by the interactive commands like vi from script command.
Jan SpringerCommented:
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.
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 ?


Thanks All !
Most likely you need to compile syslog-ng yourself to include oracle support, but yes, it is possible:

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
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

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.