- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: HOW to grep for "rm" or a specific command fro...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2011 07:53 AM
10-25-2011 07:53 AM
HOW to grep for "rm" or a specific command from users' .sh_history file?
Fellow SAs:
Can someone suggest an easy way to investigate which user issued a specific command from his/her history file. I have a list of 50 users and I want to detect who used either "rm" or "mv" command. Please forward any known "find" string or script that you may use for this kind of activity. Thanks in advance for your time and inputs.
Regards,
-Kennedy
- Tags:
- history
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2011 08:10 AM
10-25-2011 08:10 AM
Re: HOW to grep for "rm" or a specific command from users' .sh_history file?
Hi Kennedy:
First, remember that any user who wishes to hide his/her activity only has to remove his/her '.sh_history' or truncate it by redirecting '/dev/null' into it.
That said, you could try (as root):
# find /home -name .sh_history -exec grep -E "mv|rm" {} +
This assumes that the user's default shell is '.sh_history' and that its path is in '/home'. You could address this by examining '/etc/passwd' to obtain a list of users as well as their HOME login directory and shell.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2011 08:16 AM
10-25-2011 08:16 AM
Re: HOW to grep for "rm" or a specific command from users' .sh_history file?
James:
Thanks a billion.... I really appreciate it. I will try out your string/suggestion.
Other users, please keep it coming...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2011 09:29 PM
10-25-2011 09:29 PM
Re: HOW to grep for "rm" or a specific command from users' .sh_history file?
>Other users, please keep it coming...
There are not very many ways to do this. Of course the user could rename his history file and put it elsewhere with:
export HISTFILE=
You could grep his ~/.profile to check for that. And of course there is a separate history for the scummy C shell, And I suppose bash could use a different one,