0

I want to monitor the rm, mv and mkdir commands in Ubuntu Server.

How could this be achieved?

7
  • 2
    What do you mean by monitoring those commands? You want to see their progresses while operating?
    – Tung Tran
    Dec 28, 2015 at 10:02
  • I don't think there would be any progress to see for mkdir, so the question must be about logging.
    – Cos64
    Dec 28, 2015 at 10:28
  • you can use -v option to see what rm and mv are doing...
    – Alex Jones
    Dec 28, 2015 at 10:36
  • Please edit your question and explain what exact behavior do you want, what kind of monitoring do you expect. If it is closed before you can edit it, please still make an edit and leave a comment. Moderators and higher-rep users can vote to reopen the question Dec 28, 2015 at 10:41
  • 1
    Possible duplicate of Log commands executed in ubuntu
    – muru
    Dec 28, 2015 at 10:52

1 Answer 1

1

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

Not the answer you're looking for? Browse other questions tagged .