Reputation: 101
I have a requirement. I need to print a specific message while a unix command is run by any user. For example, if someone runs cat command or if cat command gets executed on command line. I need a custom message on the terminal.
Upvotes: 0
Views: 945
Reputation: 1836
Use spydig
:
sysdig -c spy_users
Alternative 1
Execute w
with watch
:
watch -n,5 w -h
w
shows you what the users actually dowatch
calls a command (w
in this case) repeatedly in a user-given time interval (0,5 seconds in this case)Alternative 2
Look in the users shell history e.g. .bash_history
:
tail -f /home/userxyz/.bash_history
Upvotes: 3
Reputation: 148
You can install the package "psacct" / "acct"
apt-get install acct
or
yum install psacct
Enable it using
systemctl enable psacct
systemctl start psacct
and now you can check everything a user runs on the system.
ac user
ac -d user
lastcomm
lastcomm user
Also check out "auditd" for more auditing and logging of events.
Upvotes: 0
Reputation: 896
Remove cat from your search path and replace it with your wrapper script. Put the original command somewhere else. Make sure you handle exit codes properly.
Upvotes: 0