How to Host a Server on LinuxYou may have heard about Linux but if you have not heres a brief introduction: Linux is an open source OS (
Operating System) created by Linus Torvalds however many organisations have added their own features and programs to it to create a distribution. These Distributions vary in complexity and size but the ones that are best known are Ubuntu, Feroda, Gentoo, Red Hat, SUSE, Slackware. There are over 300 in total so your never lacking choice like you do with Windows. Since Linux is open source and under the GNU General Public Lisence therefore everyone has access to the source code. This means that these OS's are incredibly stable and bug-free. (In the most recent Linux Kernel there were only around 900 bugs in all the 4.5 million lines of code, Windows XP on the other hand has around 20-30 bugs in every thousand lines. Thats a lot when you consider that XP contains over 40 million lines of code.) Ultimately if you run a private server on a Linux Distribution you will get a lot more out of your computer. That's enough explaining how Linux > Windows
For this Tutorial we will be following
Ubuntu since it is installed on many notebooks and is a very user-friendly: Perfect for a Linux newbie! On the other hand if you feel a bit adventurous and and not scared of a command line interface I advise you to use
Arch Linux because it uses less resources that Ubuntu does and has a fantastic Wiki which explains everything perfectly which counts me out for explaining how to install and configure it.
1. Getting and Burning Ubuntu to a discYou can obviously skip this step if you have already got Ubuntu installed on your computer.
First of all you need to get the CD image of Ubuntu. Go onto the Ubuntu Download Page[/url] select your Location (Or the closest one) from the drop down box and then click "Begin Download"
When you have downloaded the image you will need to download a image burning software. Download
ImgBurn and install it. When you have it running you want to select "Write image file to Disc" select the Ubuntu iso file and click on the large icon at the bottom.


If you already have such a program like Alcohol 120% or Nero just import the iso image and burn to a cd-r/rw or dvd-r/rw.
Note: Ubuntu 9.04 (Current Release) is 715MB which means you
must burn the image to a
DVD.
2. Installing UbuntuWARNING: You have to remember that this is a whole new Operating System and if you dont "Dual Boot (Lets you have the option of running either Windows or Ubuntu on one computer) you may even delete Windows. Please refer to the guides on how to dual bootI wont give a detailed guide into installing Ubuntu onto your computer because I think the documentation on the site is more than enough.
Something that isnt included is how changing your boot order that occasionally is necessary. To change the boot order on your BIOS you need to press "Delete" or "F2" or whatever key is assigned to "Setup", this should be shown with the logo of your computer manufacturer when you boot your computer.
When you have pressed this key you should have a screen that looks on the lines of this:

This is a basic Phenox BIOS(Very Old, notice the floppy disc drive and 4GB Hard Drive) . Yours might look similar or completely different.
Don't worry if it looks different, as long as you can find the "Boot" menu (Might be under Advanced) you are OK. Remember you have to use the arrow keys! No mouse!
Then you need to go onto Boot Order and put your CD/DVD drive
First! and press the key for exit or the Save and Exit key.
Now insert your freshly made Ubuntu CD and reboot.
The rest of the Installation is pretty easy and the nice interface will guide you through (Its all graphical). If your stuck you can always refer back to the documentation.
3. Installing Java (JRE and JDK) When you have finished the install process you should be presented with the GNOME desktop which is a nice interface that is very user-friendly. (I personally don't like it but many others do)
As you can see at the Top there is a taskbar very similar to Windows Task Bar. You need to click on "Applications" then "Accessories" and Finally "Terminal"

A window like the one above will pop up (expect it will be opaque and the first line will have your user-name which you created during the setup process). This program is much like command prompt (cmd.exe) on Windows however is used more often when you want to carry out tasking such as installing programs. Unlike Windows Ubuntu can install programs without even going to the Website on Terminal using the apt-get command.
The most important command though is "sudo" which you will need to type before pretty much all commands in Terminal. Sudo gives you "Administrator" rights so you cant make major changes by accedent. You will be asked for your password when using this command.
Before we download and install Java we need to make your the "Repository" (a place were a lot of cool programs are held) is up to date. First of all we need to check that the server settings are correct to do this we need to type:
sudo gedit /etc/apt/sources.list
Then press enter.This will open gedit (Like Notepad) you need to make sure the following lines are included:
deb http://za.archive.ubuntu.com/ubuntu/ intrepid main restricted
deb http://za.archive.ubuntu.com/ubuntu/ intrepid multiverse
Save the file and then input:
sudo apt-get update
This will update the list of programs so we can install Java.
Once that is finished you need to input:
sudo apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin
This will install JRE
and JDK with the Firefox plugin all at the same time. Its much quicker than manually downloading all those files from the Internet like you do on Windows.
Unfortunately, If for whatever reason the above fails you can download the installer from Sun's website. You must go to the "Linux" section and select:
Linux (self-extracting file)
4. Opening Rar ArchivesMost people package their work in Rar archives and unfortunately by Default you cannot open these however you can install a program that can! Get back onto Terminal if you have closed it and type:
sudo apt-get install unrar
After it has finished installing (it wont take long) you can start downloading rar files.
When you have got your first Rar file on your desktop, the default download directory for Firefox, you must right click on it and select "Open with other Application. For illustrative purposes I provided a picture similar to what you will see:

You now should click on "Use a custom Command" and type:
unrar -x
After this you can open all rar files like normal (In Ubuntu's compression program) and drag them do a folder just like WinRar.
5. Setting Path and ClasspathI should first mention that if you correctly installed java from the Repository you wont even need to do this step! However if any reason you cant update them you should run this command in Terminal:
sudo update-java-alternatives -s java-6-sun
If further problems persist you can manually edit your environment variables by running the following:
sudo gedit /etc/environment
You can replace gedit with sudo if you prefer it.
Now find the two variables called PATH and JAVA_HOME.
First find JAVA_HOME and then delete it if it exists and replace it with:
JAVA_HOME=/usr/lib/jvm/java-6-sun
Now look for PATH and after the PATH=" add this:
$PATH:$JAVA_HOME/bin:
6. Creating shell scripts to replace batch filesWith your source or client you now must now create a shell file (.sh) that does the same functions as a batch script (.bat .cmd) does, except it runs the commands in terminal. Now you have found the runserver batch script you need to open it in a text editor. You can use either gedit (an editor with a GUI and basic functions) or GNU Nano which is a
very basic editor; its only useful when you are editing a couple of words and not running a desktop environment. To open in gedit just click on the file, for nano go onto Open with other Application and on the custom command box type "nano".
You should see the normal stuff like:
@echo off
color 0a
title My Rubbish Server
java -Xmx512m -cp server
Note: server is the main class in this example, it could possibly be something else when running other servers/clients.
For a shell script you keep the main command (java -Xmx512m -cp server) and get rid of the rest. Then at the beginning of the file add the following (All shell scripts should start off with this line.):
#!/bin/bash
When you have finished editing everything it should look like this:
#!/bin/bash
java -Xmx512m -cp server
Now you just save the file using "Save as" and call it run.sh
Then in terminal in the same directory run this command:
chmod -x run
To run it
double click on run and your Server/Client should run!
To compile the basic syntax is:
#!/bin/bash
javac *.java
7.Sorting out your Router and DNS ServerThis is exactly the same as Windows!
To access your router you type (Or the default address of your router) and then make the necessary changes such as port-forwarding and adding exceptions to the firewall.
You must remember that if you like using the
no-ip duc program you must select "Linux/BSD/Unix"
Have fun running a rs server on Linux.
Ask any questions!
This is unrelated to servers however I think if your running Ubuntu and want to run some Windows executables get Wine. (sudo apt-get install wine) Then open an .exe file with "Open with another Application" and use the custom command "wine". You can now try to run Windows executables as normal.
.msi installer files are configured using the custom command "wine start"
You should remember that your program is not guaranteed to work however you can search the application database on Wine's website to make sure.