Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

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.
0
apunkabollywood
Asked:
apunkabollywood
  • 4
  • 2
  • 2
  • +2
1 Solution
 
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
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
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
 
apunkabollywoodAuthor Commented:
Thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now