Continuing from page 1 of the Debian Etch setup, we'll now configure the terminal to be more useful and readable and create some aliases so we don't repeat entering long commands.
Then we can configure the locale(s) and go ahead and update Debian to the latest secure software ready for the 'working' software such as web servers and so on.
OS check and Free
Let's confirm the Linux type and version:
I hope you get something like this:
Debian GNU/Linux 4.0
If not, you're probably logged into the wrong VPS.....
We can start our server administration straight away by looking at the memory usage:
My test VPS has 256MB of memory and 'free -m' reports usage in MB as follows:
. total used free shared buffers cached Mem: 254 37 217 0 0 9 -/+ buffers/cache: 26 228 Swap: 511 0 511
Concentrate on the second line of the output and you'll see that I am actually using 26MB of RAM with 228MB free. The first line suggested I was already using 37MB but 9MB of that is in buffers and cached.
You'll notice the terminal is a little bland and is not very informative. Let's add some colour and let it tell us which Slice we are logged into and what directory we are in. It's actually quite easy to forget simple things like this if you have more than one or two Slices!
We'll do this by editing .bash_profile to fit our needs:
To add some colour to the terminal and to show who we are and where we are, add the following line at the end of the file:
export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '
That will show the VPS name in purple and the working directory in brown.
Now we can add some aliases. An alias is simply a shortcut to a command or sequence of commands.
Some examples are:
alias free="free -m" alias aptitude="sudo aptitude" alias update="sudo aptitude update" alias upgrade="sudo aptitude upgrade" alias install="sudo aptitude install" alias remove="sudo aptitude remove"
The first example gives the memory usage in MB whenever I enter 'free' and the rest are aliases involved with the aptitude command.
Feel free to change the alias names to something else and add and remove more as you see fit. You'll get into your own habits pretty quickly.
Once happy, save the file and to activate the changes enter:
The terminal is more usable now the VPS name and current directory are shown.
Now we have some customisation completed, we need to update the software that's installed.
First thing is to update the sources.list. This is a file which contains a list of repositories from which to fetch software and updates.
Fire up your favourite text editor (I use nano) and open the sources.list file:
sudo nano /etc/apt/sources.list
The following list is installed by default:
deb http://ftp.debian.org/debian/ etch main deb-src http://ftp.debian.org/debian/ etch main deb http://security.debian.org/ etch/updates main contrib deb-src http://security.debian.org/ etch/updates main contrib
Be wary of entering repositories which are not designed for servers as some repositories, whilst 'official' do not receive security updates. The list above will suffice for most servers.
Now we need to update the list of packages available to us:
sudo aptitude update
Remember that if you have set your .bash_profile as suggested above, you will not need to enter the full command. You will only need to enter the alias 'update'.
Good. Now we have an updated list of packages we can install.
Before we install anything else we need to configure the locales package:
sudo aptitude install locales
and then configure them:
sudo dpkg-reconfigure locales
During the configuration, simply select the locale(s) you want available on your VPS. In my case I selected 'en_GB.UTF-8 UTF-8'.
Now we can get down and install the latest security updates with a full upgrade command:
sudo aptitude upgrade sudo aptitude dist-upgrade
Half way through the first command it will pause and ask if you want to set your timezone. It would be a good idea to set it here by following the terminal prompts. It's usually a good idea to select UTC as the server timezone (by entering '12' and then 'UTC').
You would have noticed that quite a few programmes were upgraded so now we need to reboot the Slice.
There's rarely any need to reboot a Linux based server but as we have changed quite a few base packages it's a good idea this time:
sudo shutdown -r now
The reboot should only take a few seconds (mine took around 10 seconds before I could log in again).
Now log back in to your VPS ready for the next stage of the Slice setup:
ssh -p 30000 email@example.com
Let's get started by installing screen. This is a great application that allows 'virtual' terminals to be opened in one console. Switching between them is done with the press of a key.
The advantages are that you can be working on more than one shell at a time, say one installing software and another monitoring network activity - all without having more than one physical shell open. If the SSH connection is cut for some reason or you have to leave the room then close the terminal and the work will still carry on in the background.
I highly recommend installing and getting used to using screen. This screen tutorial gives an excellent introduction.
sudo aptitude install screen
To start a screen session simply enter the command:
Press the space bar to remove the introduction page and to activate any custom bash_profile entries, enter:
Most software requires libraries and compilers to work properly. As you would imagine, they (nearly) all share the same libraries and compilers. If they didn't it would be a bit messy really.
Debian provides what is known as 'meta-packages'. The meta-packages are a defined set of programmes for particular situations. One such set of packages include the 'essential' programmes described above such as shared libraries and compilers.
This is a nice time saver and ensures we don't forget anything. So go ahead and install the 'essentials':
sudo aptitude install build-essential
Have a look at what is going to be installed and, once you are happy with the build-essential package, click 'Y' to continue.
Quite a lot has happened 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 Debian 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.