TransWikia.com

Running a script when a particular command is run

Unix & Linux Asked by SidJo on December 15, 2021

I want to run "./dothis.sh" if someone executes "cat abc.txt"

Is there some way to do this without using alias?

I want to use this for strengthening security of some specific files on a server.

Thanks for any help you can provide.

2 Answers

Actually, what i want is: I have a passwords file (encrypted of course) which is accessible to the root user. I want to prepare for a "break-in", per say, where the root user is compromised. So, if someone, using the root user tries to view that file with vim or cat, i want them to be locked in an infinite loop, so that they have to exit the terminal on their end. I dont want the keyboard interuption to work. But, if i use the whole path of the utility Eg."/usr/bin/cat" Then it should work. Basically... I want to create an alias where "cat " runs a custom script. I require the script as well as how to properly alias it. Thanks

Answered by SidJo on December 15, 2021

man auditd
man auditd.conf

Is what you're looking for and then you run a command once there's a line being logged:

  1. How to log all commands run on Linux including their arguments (parameters)?
  2. How to run a script on auditd events?

Answered by Artem S. Tashkinov on December 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP