0

how can I find out all the commands entered by the user?

I need to know all my entered commands OC: centOS

1 Answers1

0

On all unix-based OS's this is typically achieved by using the history command. If you want to search for a specific command in your history, you can use history | grep "cp". This command takes the output from the history command and pipes it (that's the | character) into grep which checks every line for the string cp. To limit the amount of results the history command provides, add the desired number as the first argument to history: history 15.

If you want to get the history of a different user that your current one, you have to switch to that user first: su myusername.

Keep in mind that if you open multiple sessions as one user, only the first terminal you open will actually save the history if you use bash.

If you need a combined history of all sessions of one user, I would recommend you to use a different shell, fish for example.