I have shell script for monitoring local area traffic for my system. Now I want to install it, and want to run like other unix command
I have shell script for monitoring local area traffic for my system. Now I want to install it, and want to run like other unix command
The way I would solve this (with my fairly rudimentary linux skillz) is to make an alias to the shell script.
First ensure the shell script is executable.
chmod u+x,g+x script.sh
Then, edit your .bashrc
file like following:
cd
vi .bashrc
Add this towards the bottom. (I think you can also add this in a specific alias file, such as .bash_aliases
, but I don't.)
alias commandtorun='/home/user/script.sh'
Here, commandtorun
will be the command you type in to run the script, and '/home/user/script.sh'
is the path to the script.
To save changes to your .bashrc
in vi editor, :wq
, which writes to file and quits.
Edit: You'll also need to re-source your .bashrc to use the changes in the current session. (Or just restart the session / close and reopen the terminal).
source ~/.bashrc
Good luck!