System Locale Setup on Debian 12 Bookworm Command Line

This guide intends to teach you to System Locale Setup on Debian 12 Bookworm from Command line. You will learn to check your current system locale, which one of them is enabled, generate a locale, and change the default one on your Debian 12 server.

As you know, the system locale defines the language and country-specific setting for the programs running on your server and the shell sessions. 

Steps To System Locale Setup on Debian 12 Bookworm Command Line

Before you start to set up the system locale, you must have access to your server as a root or non-root user with sudo privileges. To do this, you can visit this guide on Initial Server Setup with Debian 12 Bookworm.

Then, proceed to the following steps to complete this guide.

Step 1 – Display Default System Locale on Debian 12 From Command Line

First, you can check your current system locale on your Debian 12 server by using the command below:

locale

In your output, you will get something similar to this:

Output
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Also, you can use the following command instead to check your system locale status:

localectl status
Output
 System Locale: LANG=en_US.UTF-8
    VC Keymap: (unset)
   X11 Layout: us
    X11 Model: pc105

Step 2 – Check Which Locales are Enabled on Debian 12 Bookworm

You may have several locales set for different parts of your system. To check which locales are enabled on your Debian server, run the command below:

locale -a

In my case, I get the following output:

Output
C
C.utf8
en_US.utf8
POSIX

Step 3 – How To Generate a Locale on Debian 12 with dpkg-reconfigure Command?

If you want to enable a system locale for the region you want, you can simply use the locale-gen command. Here we use the following command to select a locale and generate it on Debian 12:

dpkg-reconfigure locales

Here as an example, we select the en_AG UTF-8 and click OK.

Generate system locale on Debian 12

Then, it will ask you to select the default system locale on your Debian 12. We select the en_US.UTF-8 and click Ok.

Select Default System Locale Debian 12

When it is finished, you will get the following output:

Output
Generating locales (this might take a while)...
  en_AG.UTF-8... done
  en_US.UTF-8... done
Generation complete.

Finally, verify your system locale is enabled on Debian 12 with the command below:

locale -a
Output
C
C.utf8
en_AG
en_AG.utf8
en_US.utf8
POSIX

Step 4 – How To Change the Default Locale on Debian 12?

At this point, you can easily change the default locale manually. For this purpose, you need to edit the /etc/default/locale file, here we use vi editor to open the file:

vi /etc/default/locale

The file has a single line that describes the default system locale on Debian 12:

LANG=en_US.UTF-8

You can change the LANG with your desired locale. When you are done, save and close the file.

Finally, log out from your current session and then log back in, or open a new terminal, to activate the new system locale.

Also, there is an alternative method that you can update the locale file without editing it. You just run the following update-locale command to set your system locale:

update-locale LANG=your-desired-locale

Remember to restart the session to activate your locale.

For more information, you can see the man pages for locale commands:

# man locale
# man update-locale
# man localectl

Conclusion

At this point, you have learned a System Locale Setup on Debian 12 Bookworm from Command Line. You have seen that you can easily use Linux Commands to change your default system locale on Debian 12. Hope you enjoy it.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!