System locale allows you to specify the language settings for the user interfaces and services running on your system. In this tutorial we will help you to set up system-wide locale settings on a Linux VPS running CentOS 7 as the operating system.
First of all, lets learn more about the system locale. The system-wide locale settings are stored in a file. The file is /etc/locale.conf and this file is read by the systemd daemon at system boot. All the settings specified in this file are inherited by the users on your system and the services running on your system. However, certain system users or services can easily override the specified system locale settings if needed.
Connect to your CentOS VPS via SSH and update your system software to the latest version available before doing anything else. Issue the following command to do that:
# yum update
The update process should take no longer than few minutes to complete. Once it completes, run the following command to check the system locale specified on your server:
# localectl status
You should see something like the following:
# localectl status System Locale: LANG=en_US.utf8 VC Keymap: n/a X11 Layout: n/a
You can check the system locale specified on your CentOS VPS by reading the /etc/locale.conf file too:
# cat /etc/locale.conf LANG=en_US.utf8
If you want to set up different system locale on your system you can do that by using the localectl command. First, list the available locales:
# localectl list-locales
The list should be very long. If you want to filter the English locales you can do that using the command below:
# localectl list-locales | grep en_
You should get something like the following:
# localectl list-locales | grep en_ en_AG en_AG.utf8 en_AU en_AU.iso88591 en_AU.utf8 en_BW en_BW.iso88591 en_BW.utf8 en_CA en_CA.iso88591 en_CA.utf8 en_DK en_DK.iso88591 en_DK.utf8 en_GB en_GB.iso88591 en_GB.iso885915 en_GB.utf8 en_HK ...
To set up a specific system locale to be a default one, you can use the localectl command:
The syntax is the following:
# localectl set-locale LANG=locale_name
Of course, you need to replace locale_name with the default locale you like to set. For example, if you’d like to set en_GB.utf8 as a default system locale you can use the command below:
# localectl set-locale LANG=en_GB.utf8
To check if everything is OK you can run the following command again:
# localectl status
Now, the output should be same like the following:
# localectl status System Locale: LANG=en_GB.utf8 VC Keymap: n/a X11 Layout: n/a
Using localectl you can set up virtual console keyboard mappings on your system too. For more information about what options are available you can use the –help flag:
# localectl --help
The output of the command above should be similar to the following one:
# localectl --help localectl [OPTIONS...] COMMAND ... Query or change system locale and keyboard settings. -h --help Show this help --version Show package version --no-pager Do not pipe output into a pager --no-ask-password Do not prompt for password -H --host=[[email protected]]HOST Operate on remote host -M --machine=CONTAINER Operate on local container --no-convert Don't convert keyboard mappings Commands: status Show current locale settings set-locale LOCALE... Set system locale list-locales Show known locales set-keymap MAP [MAP] Set console and X11 keyboard mappings list-keymaps Show known virtual console keyboard mappings set-x11-keymap LAYOUT [MODEL [VARIANT [OPTIONS]]] Set X11 and console keyboard mappings list-x11-keymap-models Show known X11 keyboard mapping models list-x11-keymap-layouts Show known X11 keyboard mapping layouts list-x11-keymap-variants [LAYOUT] Show known X11 keyboard mapping variants list-x11-keymap-options Show known X11 keyboard mapping options
Of course you don’t have to do any of this if you use one of our Managed CentOS VPS hosting services, in which case you can simply ask our expert Linux admins to set up the system locale for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.