Debian VPS setup - page 2

Continuing from page 1 of the Debian VPS 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 install and configure the locale(s) and go ahead and update the Debian install to the latest secure software.

Let's confirm the Linux type and version:

cat /etc/issue

I hope you get something like this:

Debian GNU/Linux 4.0

If not, you're probably logged into the wrong VPS.....

Memory usage

We can start our server administration straight away by looking at the memory usage:

free -m

My test VPS has 256MB of memory and 'free -m' reports usage in MB as follows:

.                  total       used     free     shared    buffers     cached
Mem:           254         97        157          0           4              63
-/+ buffers/cache:       29        225
Swap:          511          0         511

Concentrate on the second line of the output and you'll see that I am actually using 29MB of RAM with 225MB free. The first line suggested I was already using 97MB but 67MB of that is in buffers and cached.

Customise the terminal

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 VPS 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 VPSs or servers!

We'll do this by editing .bash_profile to fit our needs:

nano ~/.bash_profile

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.

For example, as an admin user I want to install programmes but find typing:

sudo aptitude install prog_name

a bit of a chore. So I'll create an alias called 'install' which will give the whole sudo command without me typing it in so next time I would just enter:

install prog_name

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"
alias search="sudo aptitude search"

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:

source ~/.bash_profile

The terminal is more usable now the VPS name and current directory are shown.

Update

Now we have some customisation completed, we need to update the software that's installed on our Debian VPS.

First thing to do 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

I use the following list:

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'.

If you get an error like this:

There are no public key available for the following key IDs: B5D0C804ADB11277
You may want to run apt-get update to correct these problems

Don't worry! The official repositories have a 'key' that identifies them. This reduces the possibility of bogus repositories. Now and then they update this key and it's possible your base Debian VPS install does not have a valid key.

This is easily remedied by installing an updated key list:

sudo aptitude install debian-archive-keyring

Once done, enter the update command again:

sudo aptitude update

Good. Now we have an updated list of packages we can install.

If you had to install the debian-archive-keyring you may have noticed some warnings about locale settings. That's because we haven't set your locale yet.

Firstly, install 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

It may 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.

Reboot

You would have noticed that quite a few programmes were upgraded so now we need to reboot the VPS.

There's rarely any need to reboot a Linux based VPS 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 less than 10 seconds before I could log in again).

Now log back in to your VPS ready for the next stage of your Debian VPS setup:

ssh -p 30000 paul@YOURIPADDRESS

That's it for page 2. The next, and final article will deal with installing 'screen', some essential base programmes and the meat of our server: a MySQL and Ruby on Rails stack with subversion and postfix support.

PickledOnion.

Digg it | del.icio.us | reddit | StumbleUpon

Comments are closed for this article.