Ubuntu Hardy setup - page 2
In page 1 of the Ubuntu Hardy 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 Hardy but let's see:
cat /etc/lsb-release
You should get an output similar to this:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04"
Good. Memory usage should be very low at this point but let's check using 'free -m' (the -m suffix displays the result in MB's which I find easier to read):
free -m
It's nice to know what is going on so let's look at that output:
. total used free shared buffers cached
Mem: 254 43 211 0 3 74
-/+ buffers/cache: 26 228
Swap: 511 0 511
The line to take notice of is the second one as the first line includes cached memory - in this demo slice I have 254MB of useable memory with 26MB actually used, 228MB free and no swap used. Nice.
.bashrc
Let's make the terminal a bit more attractive and a bit more informative by adding a few lines to our . bashrc file.
nano ~/.bashrc
Add the next 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\]: '
If you look at the existing content of the .bashrc file, you may notice some 'PS1' content already - you can change the existing content if you prefer. This method simply changes the default output.
Now we can add aliases to the file. Aliases are 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 aptitude update"
alias install="sudo aptitude install"
alias upgrade="sudo aptitude safe-upgrade"
alias remove="sudo aptitude 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 aptitude 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 issue this command:
source ~/.bashrc
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 .bashrc. For example:
export PS1='\[\033[0;32m\]\h\[\033[0;36m\] \w\[\033[00m\]: '
would give you a green and blue output.
sources.list
The Ubuntu Hardy Slice comes with a basic set of repositories but let's have a check to see what sources we are using:
sudo nano /etc/apt/sources.list
You should see the default list as follows:
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe
deb http://security.ubuntu.com/ubuntu hardy-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted universe
You can, of course, add more repositories whenever you want to but I would just give a word of caution: Some of the available repositories are not officially supported and may not receive any security updates should a flaw be discovered.
Keep in mind it is a server we are building and security and stability are paramount.
Update
Now we can update the sources so we have the latest list of software packages:
sudo aptitude update
NOTE: If you have used the .bashrc shown above you just need to enter 'update' as the alias will use the entire command. I've put the whole thing here so you know what is happening.
locales
Remember the Hardy Slice is a bare bones install so we need set the system locale:
sudo locale-gen en_GB.UTF-8
...
sudo /usr/sbin/update-locale LANG=en_GB.UTF-8
Upgrade
Now we have updated the sources.list repositories and set the locale, let's see if there are any upgrade options:
sudo aptitude safe-upgrade
Followed by a:
sudo aptitude full-upgrade
Once any updates have been installed, we can move on to installing some essential packages.
build essentials
Ubuntu Hardy has some handy meta-packages that include a set of pre-defined programmes needed for a single 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 aptitude install build-essential
Notice the programmes that are to be installed include gcc, make, patch and so on. All these are needed for many other programmes to install properly. A neat system indeed.
Enter 'Y' and install them.
done
Quite a lot happening here but now we have a secured and updated Slice.
The console is now informative and less drab, locales have been configured 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.
PickledOnion.


Article Comments:
Birger J. Nordølum commented Fri Apr 25 17:21:09 UTC 2008 ago:
bash-completion is not installed on default. So you need to add this to use sudo in a proper mather.
Birger :)
Cody commented Sun Apr 27 03:14:45 UTC 2008 ago:
For those in the USA, use this as the system locale:
sudo locale-gen en_US.UTF-8 sudo /usr/sbin/update-locale LANG=en_US.UTF-8
Eric commented Sun May 11 19:30:55 UTC 2008 ago:
Can you please explain why you are running both safe and full upgrade, doesn't full imply all of safe as well? How often should these commands be run, and should it be scheduled to run automatically?
PickledOnion commented Wed May 14 09:09:24 UTC 2008 ago:
Eric,
safe and full upgrades are different commands and can upgrade different things (see the Ubuntu documentation for details).
You wouldn't need to run a full upgrade very often.
I wouldn't recommend ever running an automatic update and upgrade as they will always need supervising.
PickledOnion
Mark commented Wed May 14 10:41:26 UTC 2008 ago:
Thanks PickledOnion - I think your tutorials are really well written
Sohail commented Mon May 19 18:09:18 UTC 2008 ago:
PickedOnion - I've got to echo Mark. These tutorials are fantastic! They are accurate, exactly what a person needs and take the "fear" out of set up from scratch. Many of us are devs that don't muck with OS config unless we have to, so we're always rusty until the next install. Your walk throughs make setup a breeze!
This is truly a value add above and beyond that distinguishes Slicehost.com.
Great work!
Jeremy Ricketts commented Tue May 27 05:06:29 UTC 2008 ago:
Wow. I just wanted to chime in here and say VERY well done. These tutorials are so thorough and so helpful.
Doug Johnston commented Mon Jun 02 19:47:31 UTC 2008 ago:
To echo everyone else, these tutorials are awesome!! I've set up 3 different VPSs over the past few years and it has ALWAYS been a headache. These instructions are clear and very easy to follow. Thanks! I already have a good feeling about the move to slicehost.
Michael commented Fri Jun 06 13:07:45 UTC 2008 ago:
Thanks for the great article, especially giving some detail about firewalling via iptables.
Keep up the great work!
Jared commented Sat Jun 07 00:33:49 UTC 2008 ago:
@Cody Thanks! Locale in the article didn't work for this US user anyway :)
brendan lally commented Tue Jun 10 06:02:27 UTC 2008 ago:
US needs following (; missing)
sudo locale-gen enUS.UTF-8 ; sudo /usr/sbin/update-locale LANG=enUS.UTF-8
Frank commented Fri Jun 13 17:20:04 UTC 2008 ago:
not only are the tutorials amazing, but if you catch him in live chat, he's also a huge help
xolotl commented Mon Jun 16 06:48:11 UTC 2008 ago:
correction missing an underscore, wouldn't that be: sudo locale-gen enUS.UTF-8 ; sudo /usr/sbin/update-locale LANG=en_US.UTF-8
MJS commented Mon Jun 16 10:43:54 UTC 2008 ago:
This is for anyone having the same problem as me.
I couldn't get the en_GB locale file to install. It wasn't in my locale list.
So I had to run this first:
PickledOnion commented Mon Jun 16 10:46:34 UTC 2008 ago:
Hi,
The locale-gen command is the first command you run.
It is in the article before you update the locale.
You must follow the article and enter all the commands or, as you discovered, it doesn't work.
PickledOnion
MJS commented Mon Jun 16 20:58:52 UTC 2008 ago:
Hmm, I sure I ran all the commands. But now I see it and feel like a dolt.
H commented Wed Jun 18 01:25:05 UTC 2008 ago:
I accidentally ran "sudo aptitude safe-upgrade" before I set the locale and so I got a lot of warnings like these:
perl: warning: Falling back to the standard locale ("C"). perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system.
The safe-upgrade command finished ok. I then set the local. Then I reran the "sudo aptitude safe-upgrade" and it didn't update anything. Does it mean the locale of my upgraded packages is now all screwed up? Do I need to re-install the slice?
Thanks.
Gokul commented Wed Jun 18 13:15:42 UTC 2008 ago:
I had to reboot for the update-locale command to take effect.