I want to monitor the rm
, mv
and mkdir
commands in Ubuntu Server.
How could this be achieved?
If you want to log the usage of these commands, you could make some shell scripts to wrap them.
For example, for rm
:
#!/bin/bash
echo $(date +"%m-%d-%Y %H:%M:%S") $USER: $0 $@ >> /tmp/rm.log
/bin/rm.real $@
Assuming you named this file rm_log.sh
, you install it like this:
$ sudo mv -n /bin/rm /bin/rm.real
$ sudo cp rm_log.sh /bin/rm
Now whenever someone uses the rm
command, you get a new line in the /tmp/rm.log
file. For example:
$ rm example.txt
$ cat /tmp/rm.log
12-28-2015 12:34:56 cos64: /bin/rm example.txt
mkdir
, so the question must be about logging.-v
option to see whatrm
andmv
are doing...