Is there a way to find a log of all the commands that have been run by a user on Ubuntu 11.10 Server? I need to find out what my friend ran to install a program.
Asked
Active
Viewed 2.3k times
2 Answers
10
If you use something like bash as a command interpreter, you could check the history.
more /home/user/.bash_history

Bahaïka
- 935
-
How can i check the history with time-stamp? When each commands were used? – Jul 02 '13 at 08:13
-
1Under what conditions are commands added to the log? I've read that the commands are only added to the log when you exit. I noticed my commands weren't being added so I thought maybe it was because I was being kicked rather than exiting. Then I tried existing and even the they weren't added. I ask because I'm only seeing a few commands from early on in my new Ubuntu installation. – mikato Jul 16 '14 at 17:38
-2
Follow these instructions (revised from this answer).
Modify the
/etc/bash.bashrc
Append the below line the end of that file
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/[ ][0-9]+[ ]//" ) [$RETRN_VAL]"'
Create a new file
/etc/rsyslog.d/bash.conf
Add the line to the file
local6.* /var/log/commands.log
Add line to the file
/etc/logrotate.d/rsyslog
.Nearby:
/var/log/mail.warn /var/log/mail.err [...] /var/log/message
Add this
/var/log/commands.log
Restart the rsyslog.
sudo service rsyslog restart
-
1This seems to be a bad copy of https://unix.stackexchange.com/a/207819/130000, and this is not an answer to the question about command already issued – pim Apr 20 '18 at 12:10