How can I check the user command history in Unix?
You get a list of currently logged in users in /var/run/utmp
(see man 5 utmp
). The history is stored in ~/.history or for bash user in ~/.bash_history. Other shells may use other history files, so it's not that easy to get really all information.
Furthermore, if a user is logged in multiple times, the .bash_history file is not always reliable.
To read the utmp
file there is a "frontend" called who
, so you could also write a shell-script to iterate over the currently logged in users.
echo $HISTFILE
Then view that file.