# Linux System Variables

Date, time, language

# 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
```

\------------------------------------------------------------------------------------------------------------------------------------------------

# Hostname

##### Show current server hostname:  


```
hostname
```

##### Show current server hostname, and other useful info:

```
hostnamectl status
```

*example output:*

```
root@test:~# hostnamectl status
 Static hostname: test
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 8c1d97558b594586af68685af4a049c9
         Boot ID: c2478c600d2b43f0bf58682f1df01013
  Virtualization: kvm
Operating System: Ubuntu 22.04.3 LTS
          Kernel: Linux 5.15.0-106-generic
    Architecture: x86-64
 Hardware Vendor: QEMU
  Hardware Model: Standard PC _i440FX + PIIX, 1996_
```

Change server hostname: