2

In Windows CMD I can write some DOS commands in a text file, with *.bat extension, then just calling the file name will execute the commands.

cd c:\myapp dir Saving the above file, for example, m.bat will make it executable by entering m in the command prompt.

In Linux I tried to wrap the command service network-manager restart in a .sh file named rn.sh after changing its mode chmod +x rn.sh to be executable I always have to enter ./rn.sh to run it.

However, I just need to enter rn to run it. In other words, I need that rn.sh file works like a program or an application. How could I do that?

SaidbakR
  • 769
  • https://askubuntu.com/questions/1069554/execute-a-shell-script-without/1069557#1069557 – j-money Nov 20 '18 at 18:10
  • 1
    put it into PATHs and actually you don't need .sh extension, just mv rn.sh rn and it will still work. But for the original script, it is better to just use alias. – Alvin Liang Nov 21 '18 at 03:54
  • @AlvinLiang your comment is a great answer. I copied the file to ~/bin as you described and it works as a breeze! – SaidbakR Nov 21 '18 at 19:00

0 Answers0