Writing a script is easy. You do have to start with [#! /bin/bash[/B] on the first line. That tells linux that this is a bash script, so if you use a shell besides bash, you may have to change it (I don't think many people do, so try it this way and see if it works).
On the following lines, just add the lines you normally type in the console. Once your done, save the file. In order to run the script, you have to make it executable, and you can do that by chmod +x scriptname.
Once you've got your script, you can either run in manually, or put a reference to it in a startup file like /etc/rc.local. For example, on my Slackware machine, I've got a firewall script called /etc/rc.firewall (which is the standard name in Slackware and a few other distros) and in the rc.inet1 file (which starts up the network in Slack) there is a line rc.firewall. So when the script hits that during boot, it starts my firewall.