I want to see all bash commands that have been run on a Linux server across multiple user accounts. The specific distribution I'm using is CentOS 5.7. Is there a way to globally search .bash_history files on a server or would it be a more home-grown process of locate | cat | grep? (I shudder just typing that out).
|
|
||||
|
|
|
Use
If your home directories are in a well-known location, it could be as simple as
Of course, if a user uses a different shell or a different value of |
|||||
|
|
You could do
But I don't really think that is much better then what you were thinking. |
|||
|
|
|
find /home -name .bash_history | xargs grep Alternatively, grep string $(find /home -name .bash_history). Note that this covers home directories in default locations. It would be better to parse /etc/passwd or invoke getent, and parse the output of that. for i in $(getent passwd | cut -d: -f6 ); do grep string ${i}/.bash_history; done |
|||
|
|
