Debian 13 Tutorial / Set the Hostname, Time Zone and UTF-8 Locale

Set the Debian 13 hostname with hostnamectl, configure the time zone and check clock synchronization with timedatectl, then generate and select UTF-8 locales with locale-gen and update-locale. Time zones control how time is displayed; locales control language and formatting conventions. Verify the applied values as well as each command’s exit status.

Save the Current Settings for Recovery

Log in as a regular user on a minimally installed Debian VM. Sudo privileges are required, and the procedure should be carried out while maintaining the SSH session and being able to open the VirtualBox console. The commands are executed inside Debian, not on the host computer.

hostnamectl --static
timedatectl
localectl status
locale
ls -l /etc/default/locale /etc/locale.conf
cat /etc/hosts

The environment for verification is a dedicated Debian 13.7 VM with systemd 257.13 and locales 2.41. The initial values were the hostname debian13-lab, timezone Asia/Seoul, and default locale en_US.UTF-8. The output may vary if the language and region selected during installation are different.

The backup directory below must not already exist. If it does, inspect the earlier lab files and choose a fresh directory name, then use that same name in all backup and restore commands. Run the first line separately and continue only if it succeeds.

sudo test ! -e /var/backups/lf-debian13-05 && sudo install -d -m 700 /var/backups/lf-debian13-05
sudo cp -a /etc/hostname /etc/hosts /etc/localtime /etc/locale.gen /etc/locale.conf /var/backups/lf-debian13-05/
hostnamectl --static | sudo tee /var/backups/lf-debian13-05/hostname-before
timedatectl show -p Timezone --value | sudo tee /var/backups/lf-debian13-05/timezone-before

If the first line fails, stop and do not run the remaining lines. In the existing configuration without /etc/locale.conf, the actual locale file is checked to adjust the backup target. The /etc/default/locale of this VM was a symbolic link pointing to ../locale.conf. Since copying only the link does not separately preserve the configuration content, the actual file is backed up.

Set the Hostname and Local Name Resolution

The host name is the name that identifies the server itself. In this exercise, the name debian13-web01, a combination of lowercase letters, numbers, and hyphens without spaces, is used. hostnamectl official manual distinguishes between the static name set by the user and the temporary name received from the network. Here, a static name that will be used even after reboot is set.

sudo hostnamectl set-hostname debian13-web01
hostnamectl --static
cat /etc/hostname
sudo nano /etc/hosts

Check that both query results are debian13-web01. In nano, only the line 127.0.1.1 with the existing name is modified. If the existing line was 127.0.1.1 debian13-lab.test debian13-lab, it is replaced as follows. Keep the localhost and IPv6 lines. Save with Ctrl+O and Enter, and exit with Ctrl+X. If nano is not available, use the installed editor.

127.0.1.1 debian13-web01.test debian13-web01
getent hosts "$(hostname)"

The result of the practice was 127.0.1.1 debian13-web01.test debian13-web01. The .test suffix is used only for local lab aliases, not as a public domain. If there is an actual internal domain, it should comply with management policies. Changing /etc/hosts affects name resolution within this server and does not create external DNS records. To connect from another computer using the new name, name resolution must also be configured separately on that computer.

Even if the old name remains in the existing shell prompt, it is not a definitive indication of a failed setting. Check the prompt in a new login and use the hostnamectl result for assessment. If a sudo unable to resolve host warning appears, first confirm that the host name and /etc/hosts alias match.

Compare UTC with the Local Time Zone

UTC (Coordinated Universal Time) is the common standard for comparing time. Korean time is 9 hours ahead of UTC. Servers operated in Korea can choose Asia/Seoul, and servers that align logs from multiple regions to a common standard can choose Etc/UTC. Apply consistently so that operational policies and log readers can understand.

timedatectl list-timezones | grep -E '^(Asia/Seoul|Etc/UTC)$'
sudo timedatectl set-timezone Etc/UTC
date '+%F %T %Z %z'
sudo timedatectl set-timezone Asia/Seoul
date '+%F %T %Z %z'
timedatectl

In the actual comparison, the first output was 2026-11-16 08:31:48 UTC +0000 and the second was 2026-11-16 17:31:48 KST +0900. Seconds may vary depending on the execution interval. Although the display changed by 9 hours, the actual time was not moved forward by 9 hours. Unaware of this difference, if the clock is moved again with set-time, it can misalign the reference for certificates, logs, and scheduled tasks.

The timedatectl manual explains that setting the time zone changes the /etc/localtime link. Keep the real-time clock (RTC) in UTC when possible; displaying local time does not require changing the RTC to local-time mode.

Verify Actual Time Synchronization

NTP (Network Time Protocol) is used to synchronize clocks with a time server. This minimal installation VM had systemd-timesyncd installed. If another time service is in use on the existing server, check that first and do not arbitrarily install multiple clients together.

systemctl is-active systemd-timesyncd
systemctl is-active chrony
sudo timedatectl set-ntp true
timedatectl show -p Timezone -p NTP -p NTPSynchronized
timedatectl timesync-status

If chrony is not present, you may get results indicating inactive or unit not found, and this alone does not mean synchronization has failed. The verification of a practice environment using timesyncd was as follows.

Timezone=Asia/Seoul
NTP=yes
NTPSynchronized=yes

NTP=yes means that the time synchronization service is active, and NTPSynchronized=yes indicates whether synchronization has actually occurred. If the network is blocked or just after boot, synchronization may not be completed even if the service is running. timesync-status is exclusive for timesyncd, so in a chrony setup, tools of the respective service such as chronyc tracking are used.

If synchronization continues to fail, check the server address, name resolution failure, and timeout in the next log. Confirm with the administrator whether DNS lookup and external NTP communication (typically UDP 123) are possible. If there is a time server designated by the organization, follow that policy. Do not try to resolve the issue of not connecting to a public time server in a network separated from the Internet by simply reinstalling the package.

journalctl -u systemd-timesyncd -b --no-pager -n 30
timedatectl timesync-status

The systemd-timesyncd manual describes a simple time synchronization client. It does not cover all advanced NTP requirements. Providing time to other devices requires a separate service design.

Generate UTF-8 Locales and Choose a Default

A locale defines the language, character classification, date, number and sorting conventions used by programs. UTF-8 encodes characters from many writing systems, including Korean. Keep en_US.UTF-8 if you want English messages and error searches. This lab also generates ko_KR.UTF-8 to demonstrate a visible language difference; you do not need Korean as the server default to work with UTF-8 files.

Settings Roles Points to Note
LANG Default locale for each item Used for selecting the general default language.
LC_TIME Date and Day Display Change date/time formatting while leaving other locale categories unchanged.
LC_ALL Override all locale categories It is useful for temporary execution, but it should not be set as a global default unconditionally.

First, check the installed locales. Names displayed like ko_KR.utf8 are also Korean UTF-8 locales. If none exist, activate the items to use in /etc/locale.gen and then generate them. If the locales package is absent, first run sudo apt update followed by sudo apt install locales.

locale -a
sudo nano /etc/locale.gen

Remove the comment markers in front of the two lines below. Leave any other locales already in use enabled.

en_US.UTF-8 UTF-8
ko_KR.UTF-8 UTF-8
sudo locale-gen
locale -a
env -u LC_ALL LC_TIME=ko_KR.UTF-8 date '+%A'
env -u LC_ALL LC_TIME=en_US.UTF-8 date '+%A'

Only LC_TIME changes between these commands. On the Monday used in the lab, the Korean command printed 월요일 and the English command printed Monday, in that order. These environment assignments affect only the individual command. The env -u LC_ALL prefix prevents an existing LC_ALL value from overriding the comparison.

The locale-gen manual distinguishes selecting locales from compiling their data. Changing LANG before generating the selected locale can produce warnings such as Cannot set LC_*.

For an optional Korean-default comparison, run the following. The final LC_ALL argument has no equals sign or value: it removes an existing LC_ALL definition from the locale configuration, rather than clearing all settings.

sudo update-locale LANG=ko_KR.UTF-8 LC_ALL
cat /etc/locale.conf
localectl status

To keep or restore English, run sudo update-locale LANG=en_US.UTF-8 LC_ALL. The Debian 13 update-locale manual specifies /etc/locale.conf as the default configuration file. In the lab VM, both the actual file and localectl display changed when the default was switched to Korean and then restored to English.

Check a New Login and Restore the Original Settings

Even if you change the global default, the environment variables of already open shells do not change automatically. Before closing an existing SSH session, open a new session and check locale and date. LANG and LC_* from the client may be passed according to the SendEnv of the SSH client and AcceptEnv of the server. If the global file and the results of the new session differ, check both the connection settings and the user's shell configuration. Do not forcibly stop the SSH service just for verification.

If Korean appears as squares or broken shapes, check the terminal's UTF-8 encoding and Korean fonts as well as the locale. Generating a Korean locale does not mean installing Korean fonts on all consoles. It is also possible to configure so that you handle Korean files in UTF-8 while keeping messages in English.

To return to the state before practice, use the initially saved materials. If there were other valid changes after practice, first check the differences between the current content and the backup.

sudo hostnamectl set-hostname "$(sudo cat /var/backups/lf-debian13-05/hostname-before)"
sudo cp -a /var/backups/lf-debian13-05/hosts /etc/hosts
sudo timedatectl set-timezone "$(sudo cat /var/backups/lf-debian13-05/timezone-before)"
sudo cp -a /var/backups/lf-debian13-05/locale.gen /etc/locale.gen
sudo cp -a /var/backups/lf-debian13-05/locale.conf /etc/locale.conf
sudo locale-gen
hostnamectl --static
getent hosts "$(hostname)"
timedatectl show -p Timezone -p NTP -p NTPSynchronized
localectl status

This recovery restores the name, hosts, time zone, and locale. If time synchronization was turned off before the practice, you should check the service policy and separately restore that state as well. Since the initial state in the example had synchronization enabled, it was maintained. The setup is considered complete when the desired name is displayed, the selected time zone and UTF-8 locale are shown, and you can verify whether time synchronization is actually active.