Localectl set locale linux

Localectl set locale linux

This tutorial describes how to update the system locale and language settings on an Oracle Linux system from the command line. This tutorial is targeted at Oracle Linux 8 users, but the localectl command can be used on other systems where systemd is installed, such as Oracle Linux 7.

Background

Many Oracle Linux systems are installed without a desktop environment. However, multiple ways using command lines are available to configure base system settings, such as the system locale and language settings.

The system locale defines the language and character set encoding used for presentation of information on a terminal and on many GUI applications as well.

Locale options are usually listed in the following format:

LANGUAGE is the ISO 639 language code, for example en for English; COUNTRY is the ISO 3166 country code, for example GB for Great Britain and the United Kingdom; CODESET is the character set or encoding, for example utf-8 . Thus, in this example, the locale is en_GB.utf8 .

A locale can be configured based on either sessions or users. For session-based configurations, set the LANG environment variable. For user-based configurations, set the LANG variable on the user’s profile or shell configuration. Thus, the variable is set each time a user logs into the system.

On Oracle Linux systems, use the localectl command to set the default system locale and language settings. The command handles the generation of locale information and sets the default values for users when they log into the system, either throught the command line or on a desktop environment. The command can also be used to set default keyboard mappings for both the command line and the desktop environment.

What Do You Need?

  • Any Oracle Linux system that uses systemd

Check the current configuration

To check the current locale and keyboard mapping configuration for a system, simply run the localectl command without any parameters, for example:

The system displays information about the current system locale and keyboard mapping configuration.

Set the default system locale

Set the default system locale, by running the following command:

Replace locale_value with the locale you have selected for the system. For a paginated listing of all available locale values, type:

Use the spacebar to page through the listing.

Set the system keyboard mappings

Set the system keyboard mapping, by running the following command:

Replace type with the appropriate keyboard mapping value for your keyboard type. For a paginated listing of all available keymap values, type:

Next Tutorial

Setting system date and time from the command line.

Want to Learn More?

Oracle Linux: Update the System Locale and Language Settings From the Command Line Interface

Copyright © 2020, OracleВ and/orВ itsВ affiliates.В

This tutorial describes how to update the system locale and language settings on an Oracle Linux system from the command line.

This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are «commercial computer software» or «commercial computer software documentation» pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.

Читайте также:  Microsoft windows distributedcom код события 10000

This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.

Источник

Locale

Locales are used by glibc and other locale-aware programs or libraries for rendering text, correctly displaying regional monetary values, time and date formats, alphabetic idiosyncrasies, and other locale-specific standards.

Contents

Generating locales

Locale names are typically of the form language[_territory][.codeset][@modifier] , where language is an ISO 639 language code, territory is an ISO 3166 country code, and codeset is a character set or encoding identifier like ISO-8859-1 or UTF-8. See setlocale(3) .

For a list of enabled locales, run:

Before a locale can be enabled on the system, it must be generated. This can be achieved by uncommenting applicable entries in /etc/locale.gen , and running locale-gen. Equivalently, commenting entries disables their respective locales. While making changes, consider any localisations required by other users on the system, as well as specific #Variables.

For example, uncomment en_US.UTF-8 UTF-8 for American-English:

Save the file, and generate the locale:

Setting the locale

To display the currently set locale and its related environmental settings, type:

The locale to be used, chosen among the previously generated ones, is set in locale.conf files. Each of these files must contain a new-line separated list of environment variable assignments, having the same format as output by locale.

To list available locales which have been previously generated, run:

Setting the system locale

To set the system locale, write the LANG variable to /etc/locale.conf , where en_US.UTF-8 belongs to the first column of an uncommented entry in /etc/locale.gen :

Overriding system locale per user session

The system-wide locale can be overridden in each user session by creating or editing $XDG_CONFIG_HOME/locale.conf (usually

The precedence of these locale.conf files is defined in /etc/profile.d/locale.sh .

/.config/locale.conf automatically generated.

Make locale changes immediate

Once system and user locale.conf files have been created or edited, their new values will take effect for new sessions at login. To have the current environment use the new settings unset LANG and source /etc/profile.d/locale.sh :

Other uses

Locale variables can also be defined with the standard methods as explained in Environment variables.

For example, in order to test or debug a particular application during development, it could be launched with something like:

Similarly, to set the locale for all processes run from the current shell (for example, during system installation):

Читайте также:  Linux tar степень сжатия

Variables

locale.conf files support the following environment variables.

Full meaning of the above LC_* variables can be found on manpage locale(7) , whereas details of their definition are described on locale(5) .

LANG: default locale

The locale set for this variable will be used for all the LC_* variables that are not explicitly set.

LANGUAGE: fallback locales

Programs which use gettext for translations respect the LANGUAGE option in addition to the usual variables. This allows users to specify a list of locales that will be used in that order. If a translation for the preferred locale is unavailable, another from a similar locale will be used instead of the default. For example, an Australian user might want to fall back to British rather than US spelling:

LC_TIME: date and time format

If LC_TIME is set to en_US.UTF-8 , for example, the date format will be «MM/DD/YYYY». If wanting to use the the ISO 8601 date format of «YYYY-MM-DD» use:

glibc 2.29 fixed a bug, en_US.UTF-8 started showing in 12-hour format, as was intended. If wanting to use 24-hour format, use LC_TIME=en_GB.UTF-8 .

LC_COLLATE: collation

This variable governs the collation rules used for sorting and regular expressions.

Setting the value to C can for example make the ls command sort dotfiles first, followed by uppercase and lowercase filenames:

To get around potential issues, Arch used to set LC_COLLATE=C in /etc/profile , but this method is now deprecated.

LC_ALL: troubleshooting

The locale set for this variable will always override LANG and all the other LC_* variables, whether they are set or not.

LC_ALL is the only LC_* variable which cannot be set in locale.conf files: it is meant to be used only for testing or troubleshooting purposes, for example in /etc/profile .

Troubleshooting

My terminal does not support UTF-8

The following lists some (not all) terminals that support UTF-8:

Gnome-terminal or rxvt-unicode

You need to launch these applications from a UTF-8 locale or they will drop UTF-8 support. Enable the en_US.UTF-8 locale (or your local UTF-8 alternative) per the instructions above and set it as the default locale, then reboot.

My system is still using wrong language

It is possible that the environment variables are redefined in other files than locale.conf , for example

If you are using a desktop environment, such as GNOME, its language settings may be overriding the settings in locale.conf .

KDE Plasma also allows to change the UI’s language through the system settings. If the desktop environment is still using the default language after the modification, deleting the file at

/.config/plasma-locale-settings.sh ) should resolve the issue.

If you are using a display manager in combination with accountsservice , follow the instructions in Display manager#Set language for user session.

LightDM will automatically use accountsservice to set a user’s locale if it is installed. Otherwise, LightDM stores the user session configuration in

/.dmrc . It is possible that an unwanted locale setting is retrieved from there as well.

Источник

Localectl set locale linux

This tutorial describes how to update the system locale and language settings on an Oracle Linux system from the command line. This tutorial is targeted at Oracle Linux 8 users, but the localectl command can be used on other systems where systemd is installed, such as Oracle Linux 7.

Background

Many Oracle Linux systems are installed without a desktop environment. However, multiple ways using command lines are available to configure base system settings, such as the system locale and language settings.

The system locale defines the language and character set encoding used for presentation of information on a terminal and on many GUI applications as well.

Locale options are usually listed in the following format:

LANGUAGE is the ISO 639 language code, for example en for English; COUNTRY is the ISO 3166 country code, for example GB for Great Britain and the United Kingdom; CODESET is the character set or encoding, for example utf-8 . Thus, in this example, the locale is en_GB.utf8 .

A locale can be configured based on either sessions or users. For session-based configurations, set the LANG environment variable. For user-based configurations, set the LANG variable on the user’s profile or shell configuration. Thus, the variable is set each time a user logs into the system.

On Oracle Linux systems, use the localectl command to set the default system locale and language settings. The command handles the generation of locale information and sets the default values for users when they log into the system, either throught the command line or on a desktop environment. The command can also be used to set default keyboard mappings for both the command line and the desktop environment.

Читайте также:  Как воспроизвести mpg windows

What Do You Need?

  • Any Oracle Linux system that uses systemd

Check the current configuration

To check the current locale and keyboard mapping configuration for a system, simply run the localectl command without any parameters, for example:

The system displays information about the current system locale and keyboard mapping configuration.

Set the default system locale

Set the default system locale, by running the following command:

Replace locale_value with the locale you have selected for the system. For a paginated listing of all available locale values, type:

Use the spacebar to page through the listing.

Set the system keyboard mappings

Set the system keyboard mapping, by running the following command:

Replace type with the appropriate keyboard mapping value for your keyboard type. For a paginated listing of all available keymap values, type:

Next Tutorial

Setting system date and time from the command line.

Want to Learn More?

Oracle Linux: Update the System Locale and Language Settings From the Command Line Interface

Copyright © 2020, OracleВ and/orВ itsВ affiliates.В

This tutorial describes how to update the system locale and language settings on an Oracle Linux system from the command line.

This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are «commercial computer software» or «commercial computer software documentation» pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.

This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.

Источник

Оцените статью