How to Create a Script in Linux

Courant
Have scripts start up when you boot into Linux is not hard at all. I recently had a problem with Linux running my wireless card at start up. It wasn't working and each time I would have to enter in the same commands into terminal to get my wireless on to connect to a wireless network.

To get my wireless to work I would have to run four commands in terminal each time I rebooted and this was unacceptable. So I decided to create a little script so I could just click once and it would automatically run each command for me, so I didn't have to type them in each time.

To create a script to run multiple commands in order just right click anywhere on your Ubuntu desktop and select create Document>Empty File then enter in a name for the file. Once it is created double click it to open and edit it. Once inside type in your commands to be run in a terminal, by putting each command on a separate line. Now save it and close it.

Once this is done we need to make the script executable. What does that mean? To make the script executable means to make it able to run as a script and not just be a document of boring text. You can do this via the terminal but its much easier to right click the document you just created and click properties then go to the "permissions" tab and click the check box next to the thing that says, "Allow executing file as program" then pick close.

Now we need to make your script run on boot up automatically. To do this wee need to move your script to this path; /etc/init.d/ to do that let first move your script from your desktop into your home folder.

We initially created your script on your desktop so move your mouse to your gnome panel and select places>home folder. A file browser will open looking into your home folder so now just drag your script from your desktop into this new window and now it is in your home folder.

Now we will move it into /etc/init.d/ by using the terminal because we need sudo root privileges to do this. So open up a terminal and type:

sudo mv script-name /etc/init.d

with the script-name being the name of your script and yes Linux is case sensitive so if you used upper or lowercase letters they have to match. Next we need to get it all to update so run:

sudo update-rc.d script-name defaults

Now your script should be added to the start up and you can reboot your computer and watch it work!

Published by Courant

A college student who love technology and minimal running. I have run in everything from Newtons down to Luna Sandals and love to share my minimal running knowledge  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.