As a Linux user you might prefer to use a different language for your desktop environment than the default system-wide setting. The same applies for keyboard layout or input method for a Linux user account. During a Linux server / Workstation installation you’re prompted to set your preferred language and input method before the first login.
If the prompt did not appear, then the easiest way for a user to adjust preferred language and input method settings is to use the Region & Language application in your Desktop Environment. If Desktop is not an option for you, use command line interface to configure another language as default by setting the LANG variable.
In most Linux installations, the system’s default language is set to US English, using the UTF-8 encoding of Unicode as its character set (en_US.utf8). If this is not usable in your case, you can change after installation. Below is a table showing the common lang packs Suffix and matching $LANG value.
|Language||Language suffix||$LANG variable value|
Set System-wide Default Language Settings
If you run localectl command with no arguments, it displays the current system-wide locale settings.
# On my Ubuntu 20.04 $ localectl System Locale: LANG=en_US.utf8 VC Keymap: n/a X11 Layout: us X11 Model: pc105 # On my Rocky Linux 8 VM $ localectl System Locale: LANG=en_US.UTF-8 VC Keymap: us X11 Layout: us
To set the default system-wide language, run the command:
localectl set-locale LANG=locale
- locale is the appropriate value for the LANG environment variable
Here an example for setting system-wide default language to Russian:
sudo localectl set-locale LANG=ru_RU.utf8
The change is stored in /etc/locale.conf and it takes effect for system users on their next login.
$ cat /etc/locale.conf LANG=ru_RU.utf8
Confirm after re-login:
$ echo $LANG ru_RU.utf8
Installing Language packs
If you get an error message similar to below:
Failed to issue method call: Locale ru_RU.utf8 not installed, refusing.
It means you need to install language packages that add support for specific languages.
RHEL / CentOS / Rocky / Fedora
On a RHEL based system you can run the command below to list all matching RPM packages for langpacks:
$ sudo yum search langpacks
The Russian langpacks meta-package is named langpacks-ru.noarch, which can be installed using yum package manager:
$ sudo yum install langpacks-ru.noarch Last metadata expiration check: 1:24:07 ago on Tue 06 Jul 2021 12:31:51 PM UTC. Dependencies resolved. ================================================================================================================================================================== Package Architecture Version Repository Size ================================================================================================================================================================== Installing: langpacks-ru noarch 1.0-12.el8 appstream 8.4 k Installing weak dependencies: glibc-langpack-ru x86_64 2.28-151.el8 baseos 513 k Transaction Summary ================================================================================================================================================================== Install 2 Packages Total download size: 522 k Installed size: 3.9 M Is this ok [y/N]: y
Ubuntu / Debian based Systems
On a Debian based system search operation can be done with below command:
sudo apt update sudo apt search language-pack
Specific to Russian Language.
$ sudo apt search language-pack-ru Sorting... Done Full Text Search... Done language-pack-ru/focal-updates 1:20.04+20210121 all translation updates for language Russian language-pack-ru-base/focal-updates 1:20.04+20210121 all translations for language Russian
We can then install:
$ sudo apt install language-pack-ru-base language-pack-ru Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: language-pack-ru language-pack-ru-base 0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. Need to get 2552 kB of archives. After this operation, 13.4 MB of additional disk space will be used. Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 language-pack-ru-base all 1:20.04+20210121 [2550 kB] Get:2 http://nova.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 language-pack-ru all 1:20.04+20210121 [1896 B] Fetched 2552 kB in 1s (4905 kB/s) Selecting previously unselected package language-pack-ru-base. (Reading database ... 69952 files and directories currently installed.) Preparing to unpack .../language-pack-ru-base_1%3a20.04+20210121_all.deb ... Unpacking language-pack-ru-base (1:20.04+20210121) ... Selecting previously unselected package language-pack-ru. Preparing to unpack .../language-pack-ru_1%3a20.04+20210121_all.deb ... Unpacking language-pack-ru (1:20.04+20210121) ... Setting up language-pack-ru (1:20.04+20210121) ... Setting up language-pack-ru-base (1:20.04+20210121) ... Generating locales (this might take a while)... ru_RU.UTF-8... done ru_UA.UTF-8... done Generation complete.
Please note that our table did not reflect all langpacks available on your system. There are many resources available on the internet that can show you language prefix and expected $LANG value. We hope this guide was helpful and would like to thank you for reading through.
More articles on basic Linux administration: