Skip to main content

Locale, Date & Time

Locale

In Linux, a locale is a set of environment variables that defines the language, country, and character encoding settings for a user's environment. Locales affect various aspects of a program's behavior, such as the way dates and times are displayed, the format of numbers, the sort order of strings, and the language used for messages.


View locale configuration

localectl

and

locale

View specific locale variable option

locale LC_NUMERIC

View available locales

localectl list-locales

Setting locale
localectl set-locale LANG=fr_FR.utf8

(reboot may be required)


Time


Check system time
date

or for more detail

timedatectl

NTP

View current NTP configuration:
timedatectl show-timesync --all
Enable NTP
timedatectl set-ntp on
Disable NTP
timedatectl set-ntp off
NTP Server selection

Most mainstream Linux distributions come with NTP servers preconfigured, these can be altered however, this is done via the /etc/systemd/timesync.conf file. Simply add a new line to the file formatted as follows:

NTP=NTPSERVERHOSTNAME

Timezone

Check available timezones
timedatectl list-timezones
Set server timezone
timedatectl set-timezone timezonename

The available timezone files are stored within theĀ /usr/share/zoneinfo directory. The /etc/localtime is used to set the current local timezone. This is done via a symlink to the appropriate zone info file;

daniel@jump:~$ ls -la /etc/localtime 
lrwxrwxrwx 1 root root 27 May 30 06:27 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC