Can I see what other users type/execute via SSH in my server via bash or shell?


Read the user history file from their home directory.

less .bash_history

And if needed then with timestamps too on history command.

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc

source ~/.bashrc

Without changing their shell, the best bet would be to read their shell's history file in their home directory.


I would do something like this:

ssh -l user cat ~/.bash_history
  • 3
    If it's your machine, why would you SSH back to it to look at a local history file? – thrig Mar 22 '17 at 13:49
  • @thrig, this uses SSH from another machine to display commands executed. It's pretty close to the question title. ;) – Wildcard Jul 8 '17 at 5:00

Simply type:

more ~/.bash_history

This will show each and every command that has been executed using an SSH session except the one which you are currently using (if any).

Note: Tested on Solaris 11.3, Oracle Linux 7.2 and Ubuntu 16.04

  • I'm not sure, but I don't think this address the question of what other users type. – Jeff Schaller Jun 12 '17 at 15:25
  • I tried executing commands on my server using SSH session from another server. It is listing all the commands I executed using that SSH session. – Amit24x7 Jun 12 '17 at 15:34
  • emphasis on other users – Jeff Schaller Jun 12 '17 at 15:48

Tools are available now that may not have been when the question was asked 2+ years ago. This may not be exactly what OP was asking for either, but it could be valuable for other readers.

You may want to consider tlog and the cockpit-session-recording package. Red Hat seems to be promoting these tools with RHEL8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.