In this example the file will be called myShell
First of all we will need to make this file we can just start off by typing the following:
sudo nano myShell
Notice we didn't put the .sh
extension?
That's because when we run it from the terminal we will only need to type myShell
in order to run our command!
Now, in nano the top line MUST be #!/bin/bash
then you may leave a new line before continuing.
For demonstration I will add a basic Hello World!
response
So, I type the following:
echo Hello World!
After that my example should look like this:
#!/bin/bash
echo Hello World!
Now save the file and then run this command:
chmod +x myShell
Now we have made the file executable we can move it to /usr/bin/
by using the following command:
sudo cp myShell /usr/bin/
Congrats! Our command is now done! In the terminal we can type myShell
and it should say Hello World!