How to create a script in Ubuntu

I’m not very skilled when it comes to using the command line in Ubuntu so these instructions may be incomplete. Follow them at your own risk. It would probably be a better idea to learn how to do this from other resources such as https://help.ubuntu.com/. If you still want to try to follow my instructions then your are brave indeed.

To quickly perform repetitive tasks from the command line in Linux you can create a script. Here are the basic steps:

1. Create a text file containing the command or commands you want to perform.
2. Use the chmod command to make the text file executable:

sudo chmod +x /usr/local/bin/sampleprogram

If the text file you created was called “sampleprogram” and it is in the /usr/local/bin directory then to run the command you will need to issue the command like this:

cd /usr/local/bin
./sampleprogram

Putting the dot and then the slash in front of your command tells the command interpreter that you want to run the command called “sampleprogram” that is in the current directory.