Thursday, May 2, 2024
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 38829  / 2 Years ago, wed, march 16, 2022, 4:06:36

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


More From » command-line

 Answers
7

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!


[#34016] Thursday, March 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
olouredping

Total Points: 259
Total Questions: 100
Total Answers: 121

Location: New Caledonia
Member since Wed, Sep 15, 2021
3 Years ago
olouredping questions
;