What is a script and how do I write one?
There is number of scripting languages available. The most common under Linux might be Bash, Phyton and Perl. They all have their advantages and disadvantages. It is a very vast field. For starters I'd recommend the Bash Guide for Beginners to learn how to automate routine tasks. Bash is ideal because it is present in almost all Linux distributions and often even the default shell - when you learn bash scripting you also learn how to use the shell very effectively. So that's a plus with Bash. Personally I like Perl the most.
What all scripting languages have in common is that you write a regular text file containing commands. These files are called scripts A script file should start with a line specifying the interpreter of your choice language (i.e. the program that executes the command in your text file). An example for this line would be this:
#!/bin/bash
That tells your computer the following lines are bash commands to be executed with bash shell. What the available commands are can be learned in the various guides.
Once you have written that file, you need to make it executable. Say your file is named foo.sh
than this line in a shell would make it executable:
chmod +x foo.sh
After that you can run the script typing:
./foo.sh
hitting ENTER afterwards. A very easy example for a full script would be:
#!/bin/bash
# This script prints "Hallo world X" five times
#+where 'X' is a number from 1 to 5.
for i in 1 2 3 4 5; do
echo "Hallo world $i"
done
And that's how I wrote and executed it in gnome-terminal, which is the default graphical terminal in Ubuntu: