Is there a way to create flag scripts in ubuntu that go off when a particular command is executed in the terminal, like for example when I execute
sudo ifconfig wlan0 down
Another script would get executed.
How can I accomplish this ?
Is there a way to create flag scripts in ubuntu that go off when a particular command is executed in the terminal, like for example when I execute
sudo ifconfig wlan0 down
Another script would get executed.
How can I accomplish this ?
I'm not sure if what you're asking is possible directly, but here's one option:
Create a bash script to perform all the tasks you want. Here's an example to help you get started (as for more advanced usage, Google is your friend).
#!/bin/sh
sudo ifconfig wlan0 down
command-to-execute1
command-to-execute2
etc...
Modify that code and save to a file, e.g. wlan-down.sh, then run chmod +x wlan-down.sh
and run it with ./wlan-down.sh
.
If you don't want to remember where the script is located and want to be able to simply run it anywhere, you can create an alias for it.
To create an alias, simply write alias wlandown="/path/to/wlan-down.sh"
. You should be able to write wlandown in the terminal, and then it will run your script.
If you want to store the alias permanently you need to add it to .bashrc in your home directory.
As you can see, combining these two things can give you a powerful, yet simple way to run complex commands with minimal effort.