Ubuntu Intrepid setup - page 2

In page 1 of the Ubuntu Intrepid 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 Intrepid but let's see:

cat /etc/lsb-release

You should get an output similar to this:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.10
DISTRIB_CODENAME=intrepid
DISTRIB_DESCRIPTION="Ubuntu 8.10"

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:           256         58        197          0          2         19
-/+ buffers/cache:         35        220
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 256MB of useable memory with 35MB actually used, 220MB 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 Intrepid 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/ intrepid main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ intrepid main restricted universe

deb http://archive.ubuntu.com/ubuntu/ intrepid-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ intrepid-updates main restricted universe

deb http://security.ubuntu.com/ubuntu intrepid-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu intrepid-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 Intrepid 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

NOTE: 'US' may be substituted for 'GB' if you so prefer.

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

Mike

Article Comments:

m commented Mon Dec 08 17:39:52 UTC 2008:

If you're going to use ISPConfig, remember to also open port 81.

cullepm3 commented Sun Dec 28 03:56:50 UTC 2008:

I'm seeing strange characters like ^A in the man pages and on aptitude menus. If I unset the LANG variable, the garbage goes away. Any ideas what the root problem is? Is this related to locale-gen / update-locale commands above?

Matt Alexander commented Tue Feb 10 06:12:23 UTC 2009:

I'm having the same problem as cullepm3. Anyone having the same issues (I replaced "GB" with "US")?

Michael Glass commented Thu Mar 05 01:06:37 UTC 2009:

I would highly reccomend any new install have etckeeper installed at a very early date.

sudo aptitude install etckeeper sudo etckeeper init sudo etckeeper commit

voila. etckeeper keeps a git repository of your etc directory for safekeeping and commits on every apt/aptitude call.

guvnrDOTcom commented Thu Mar 05 19:10:23 UTC 2009:

cracking guide Mike. Big cheers, went smooth as pie.

Grease commented Sat Mar 07 15:58:18 UTC 2009:

Hi,

Nice article - I am having one problem though. When I type the following command: sudo /usr/sbin/update-locale LANG=en_GB.UTF-8 I get the following message: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_IN" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").

Further, the subsequent aptitude upgrades continue to through the same message. I tried a few things by looking at some forums (like editing /var/lib/locales/supported.d/local), but it hasn't worked for me.

Any thoughts?

Nate commented Fri Mar 20 02:58:58 UTC 2009:

For those in the USA, use this as the system locale: sudo locale-gen enUS.UTF-8 sudo /usr/sbin/update-locale LANG=enUS.UTF-8

Bruce P. Henry commented Sat Mar 21 01:16:14 UTC 2009:

@Nate

That doesn't seem to work for me at all.

update-locale: Error: invalid locale settings: LANG=enUS.UTF-8

Mike commented Sat Mar 21 15:57:25 UTC 2009:

@Bruce, don't forget the underscore between'en' and 'US': sudo locale-gen en_US.UTF-8 sudo /usr/sbin/update-locale LANG=en_US.UTF-8

Diego commented Tue Mar 24 03:58:41 UTC 2009:

Does the Locale settings explained here affect the php GMT time settings and this kind of stuff? What happens if I don't generate this at all?

Marty Falatic commented Tue Mar 31 08:20:34 UTC 2009:

For those with the ^A problem (which I saw as well based on this method):

In my experience I always had LANG set to "C" in my startups (.bashrc or .cshrc or whatnot). In bash, you can test this with "export LANG=C" and try "man ls" or something again to see that the ^A chars are gone.

I'm not suggesting this is the best way to do things, but it certainly solves a few weird problems I've run into over the years (including Perl and Java weirdness).

Chad commented Wed Apr 01 09:22:59 UTC 2009:

not sure if it helpful; when I run-- "sudo /usr/sbin/update-locale LANG=en_US.UTF-8" I get errors, but if I run it as root they don't appear.

Kyle commented Thu May 14 23:09:23 UTC 2009:

After you run locale-gen command you should run: sudo dpkg-reconfigure locales Then sudo /usr/sbin/update-locale should work fine.

Kyle Rabe commented Fri Jun 19 17:47:14 UTC 2009:

I realize that this article is for Intrepid, but since there's no Jaunty article yet, I'll add some info about an issue that I've encountered. Basically, I received an error when trying to update the locale, and once I got around that, I couldn't get the locale to hold at the user level (only root).

First, I had to apt-get/aptitude install language-pack-en (might not be necessary...), then create the locale as shown, then run dpkg-reconfigure locales, then update the locale as shown. This, however, only worked for root, so I added these two lines to the bottom of my .bashrc (and to /etc/skel/.bashrc for new users):

export LANG=en_US.utf8 export LCALL=enUS.utf8

I'm not sure why the global settings didn't work at the user level for me, but they didn't, even after a reboot. If I've done something idiotic, feel free to say so, but it's all that I could figure out for now.

Dwain commented Mon Jul 27 07:21:06 UTC 2009:

I suggest you set your time zone via: dpkg-reconfigure tzdata

Justin Louie commented Wed Aug 12 23:54:51 UTC 2009:

Thanks Mike for this. It really helped me, a n00b at Ubuntu to get his slice up and running.

madra commented Sat Sep 19 10:37:39 UTC 2009:

command to set timezone:

sudo /usr/sbin/dpkg-reconfigure tzdata

['dpkg-reconfigure tzdata' by itself, as quoted above will just generate a 'command not found' error at this stage of setting up the server, as path to the command willnae have been added to '$PATH' yet]

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)