In page 1 of the Ubuntu LTS setup, we completed the ssh configuration along with a basic iptables install.
Let's move on and install some personal configuration files to make our life easier. Once done, we can update the install and create a solid base for the 'meat' of the server.
OS check and Free
First thing is to confirm what OS we're using. We know we should be using Ubuntu LTS but let's check:
You should get an output similar to this:
#Ubuntu 6.06 LTS \n \l
Now let's see how our memory usage is doing (the -m suffix displays the result in MB's which I find easier to read).
It's nice to know what is going on so let's look at that output:
. total used free shared buffers cached Mem: 254 68 185 0 2 38 -/+ buffers/cache: 27 227 Swap: 511 0 511
The important line is the second one as the first line includes cached memory - in this demo slice I have 254MB memory in total with 27MB actually used, 227MB free and no swap used. A good start I think.
Let's make the terminal a bit prettier and bit more useful by adding a few lines to our .bash_profile file.
We need to add a few lines at the end of the existing text. The following line will make the terminal show the server name in colour and display the working directory (the directory we are in) in a different colour:
export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '
Now we'll add some aliases to the file. Aliases are simply short cuts to commands or sequences of commands. I've included a few below but you can have as many or as few as you want.
alias free="free -m" alias update="sudo apt-get update" alias install="sudo apt-get install" alias upgrade="sudo apt-get upgrade" alias remove="sudo apt-get remove"
The examples above are pretty simple. Instead of typing 'free -m' every time I want to look at the memory usage, I just type 'free. Typing 'sudo apt-get install' can get tedious, so I just type 'install'.
I still need to provide my password for the sudo command to work, but it is more productive/quicker/easier to have short cuts.
To activate the changes we can either log out and log in again (a bit much!) or issue the following command:
You should now see the slice name in purple and the working directory in brown.
To change the colours to your choosing, adjust the 0;35m and the 0;33m values in the 'export PS1' line of your .bash_profile. For example:
export PS1='\[\033[0;32m\]\h\[\033[0;36m\] \w\[\033[00m\]: '
would give you a green and blue output.
Fun time over! We need to update the software catalogue now, but let's check the sources list that Ubuntu uses. So open up the file:
sudo nano /etc/apt/sources.list
You will see the default list as follows:
deb http://archive.ubuntu.com/ubuntu/ dapper main restricted universe deb-src http://archive.ubuntu.com/ubuntu/ dapper main restricted universe deb http://archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe deb-src http://archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe deb http://security.ubuntu.com/ubuntu dapper-security main restricted universe deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted universe
The defaults should suffice for most needs. You are free to add and change the repositories as you see fit but I would give a word of warning: some repositories, whilst classed as 'official' may not receive any security updates should an exploit be found.
Remember we are building a server and not a desktop here so we should be aiming for stability and security at all times.
Once done, issue the command:
sudo apt-get update
NOTE: If you have used the .bash_profile shown above, you do not need to give the whole command. You just need to enter 'update' and the alias will give the entire command. I've put the whole thing here so you know what is happening.
From the terminal output you will see the download of the updated package list.
The first thing we need to do is install some language packs. In my case I install the english ones. You may want to change it to your chosen language. We do this before updating anything else so the install does not throw up warnings and errors about locations and so on.
sudo apt-get install localeconf language-pack-en
NOTE: Again, if you use the .bash_profile aliases, you only need to type in 'install package_name' and not the whole command shown above.
Review what it's going to install and press 'Y'.
The install will ask a couple of questions: Answer 'yes' to both.
Now let's update the installed software to the latest Ubuntu LTS ones:
sudo apt-get upgrade
Have a look at what is going to happen and press 'Y'.
That might take a little while to finish and when it is done we're going to reboot the server. It's one of the few times we'll reboot. We need to do it now as there may have been some significant changes in the base/minimal install. It simply ensures that all the init files and configurations are running nice and smoothly.
sudo shutdown -r now
That command tells it to shutdown, reboot and to do that right now!
You will be 'thrown' off the terminal. Wait a minutes or two (it doesn't take long) and log back in . If you want, you can also see the output of the reboot via the Ajax console in the Slicehost control panel.
Just login and click 'console' above your slice name. It's not essential to view it, but if you are new to servers, it can give a good idea of what happens in the boot process and may give an idea if something goes wrong.
Naturally, you can view the logs as well, but this is a nice and easy way of seeing the 'live action'.
My reboot took about 15 seconds. So log in:
ssh -p 30000 demo@YOURIPADDRESS
First thing to do is install 'screen'. This is a great utility that allows us many 'virtual' terminals in our single terminal window.
It also has the ability to start a process and be left to it. The connection could drop or you can log out from work and log in again later from home to see how the process is doing. A 'normal' ssh connection will not do that - if the connection drops, the process stops which is very annoying when you're an hour into compiling GCC, as you have to start again!
So, let's install screen:
sudo apt-get install screen -y
Did you notice the -y at the end of the command? This tells the install to go ahead and not ask if I want to carry on. Not always recommended but it's safe here.
If you've never used screen before, have a look at this screen tutorial which also includes how to create a .screenrc file so it starts exactly how you want it to (my screen session starts with 3 terminals, one running 'top, one main work terminal and a spare terminal for other use).
Let's start screen:
Press the 'Space Bar' and it looks just like the normal terminal, except the .bash_profile has not been initiated... Issue the 'source' command:
Now we are back to using our aliases and useful bash prompt.
Ok, last thing to do is install some common programmes that will save time and, possibly, frustration later on.
Ubuntu has some handy meta-packages that include a number of programmes needed for one purpose. So instead of installing a dozen different package names, you can install just one meta-package. One such package is called 'build-essential'. Issue the command:
sudo apt-get install build-essential
Notice the programmes that are to be installed include gcc, make, patch, headers and so on. All these are needed for many other programmes to install properly. A neat system indeed. Click 'Y' and install them.
Quite a lot happening here but now we have a secured slice.
The console is now informative and less drab and we can use the handy 'screen' tool.
The slice sources have been updated, the slice upgraded and the meta-package build-essential has been installed.
If you do this more than once or twice it doesn't take long at all and we now have the ideal base to install the 'meat' of our server - whether the primary task is to serve web pages, act as a database server, be a file repository and so on.