Check & Change Ubuntu Locale

Overview

I recently moved some of my hosted servers to Digital Ocean for their low cost, SSD tiers. On doing so I noticed the time was out by few ours only to realise NTP was not installed and also the time was set to EST. This lead me to check the other settings around locale and discovered the Ubuntu image on Digital Ocean (and possibly others) default to US on EST.

Time

Date and time are one of the easiest things to check:
date
This will out the full date and time including timezone as any user.

To perform an adhoc / one off time sync the command is
sudo ntpdate [server]

For example:
sudo ntpdate pool.ntp.org

To find out the current timezone:
cat /etc/timezone

To change the timezone either replace the entry in /etc/timezone with the correct one e.g:
sudo echo "Europe/London" > /etc/timezone

or using a wizard:
sudo dpkg-reconfigure tzdata

Automatic Time Sync

sudo apt-get install ntp

By default it uses Ubuntu’s time servers. If you want to change it edit /etc/ntp.conf and replace the section:

server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

For example:

server 0.uk.pool.ntp.org
server 1.uk.pool.ntp.org
server 2.uk.pool.ntp.org
server 3.uk.pool.ntp.org

Restart NTP service for the changes to take effect:
sudo service ntp restart

Locale

Locale is set on a per user, per session basis. This means unless the user has overriden the default in their .bashrc file then they will be using the system default. The default Locale is set in /etc/default/locale and if changed it’s a matter to disconnecting and reconnecting to pick up the new locale.

The default for UK should be set to:
LANG="en_GB.UTF-8"
LANGUAGE="en_GB:en"

Run the generate command to regenerate the locale settings:
sudo locale-gen

Summary

Trival things but sometimes make a big difference. The Locale can affect date formatting to character sets used in files. For example a server used as source control to keeping times in check automatically.

How to set the timezone on Ubuntu Server
How To Set Up Time Synchronization on Ubuntu 12.04
Locale

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Linux and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.