Localectl set locale linux

Learn How to Localize Your Installation on Oracle Linux

Many Oracle Linux systems are installed without a desktop environment. However, multiple ways of using the command line are available to configure base system settings, such as the system hostname.

This tutorial describes how to configure the system hostname, locale, language, and date and time from the command line. This tutorial is targeted at users of Oracle Linux 8 or later.

Objectives

Upon completion of this Lab you will be able to:

  • Set the system host name
  • Set the system locale and system language
  • Set the system date, time and time zone

Prerequisites

Update the System Hostname

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

In other distributions, configuring the system hostname typically involves editing system files, such as /etc/hostname and /etc/hosts , running the hostname command to set the hostname, and rebooting the system. With Oracle Linux, the process is simplified through the hostnamectl command.

    Review the static and transient hostnames for your Oracle Linux 8 system:

Note: The static hostname is the default host name for the system and is configured in the /etc/hostname file. The transient hostname represents the name that is set for the system by services such as DHCP or mDNS after a system boot. If the transient hostname is not set, the system uses the static hostname.

sudo hostnamectl set-hostname myoracle.oraclehost 
sudo hostnamectl set-hostname --pretty "My Oracle Linux 8 Server" 

Note: A pretty hostname is a friendly free-form system name that is displayed in user interface environments. Normally, the transient hostname and the pretty hostname are identical. However, with the hostnamectl command, you can set different values for each.

Update the System Locale and Language

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.

    Review the current system locale:

sudo localectl list-locales 
sudo localectl set-locale en_GB.utf8 

Note: 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_COUNTRY.CODESET[@MODIFIERS] . The LANGUAGE is an ISO 639 language code, for example en for English; COUNTRY is an 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 .

sudo localectl list-keymaps 
sudo localectl set-keymap gb 

Note: A locale can also be configured for a specific sessions or user. 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 environment variable is set each time a user logs into the system.

Update the System Date and Time

Use the timedatectl command to set the system date and time. The command updates the real time clock (RTC), also known as the hardware clock, as well as the system clock that is maintained by the system kernel.

Читайте также:  Вопросы по альт линукс

    Review the current system date and time configuration:

sudo timedatectl list-timezones 
sudo timedatectl list-timezones | grep 'Los_Angeles' 
sudo timedatectl set-timezone America/Los_Angeles 
sudo timedatectl set-time '2100-01-01 00:00:00' 

Note: If the NTP service is set to active, your system’s date and time are automatically synchronized with the configured NTP server. In that scenario, you cannot directly modify the date or time on your system.

For More Information

Learn how to use chrony to synchronize the system date and time over the network: https://docs.oracle.com/en/learn/config_chrony_linux_8/

The video demonstration and tutorial provided at https://www.youtube.com/watch?v=q8VlYiF5sx8 is also useful if you need more information on configuring the date and time from the command line interface.

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.

Learn How to Localize Your Installation on Oracle Linux

Copyright © 2021, Oracle and/or its affiliates.

Источник

Localectl set locale linux

NAME

localectl - Control the system locale and keyboard layout settings

SYNOPSIS

localectl [OPTIONS. ]

DESCRIPTION

localectl may be used to query and change the system locale and keyboard layout settings. The system locale controls the language settings of system services and of the UI before the user logs in, such as the display manager, as well as the default for users after login. The keyboard settings control the keyboard layout used on the text console and of the graphical UI before the user logs in, such as the display manager, as well as the default for users after login.

OPTIONS

The following options are understood: -h, --help Prints a short help text and exits. --version Prints a short version string and exits. --no-pager Do not pipe output into a pager. --no-ask-password Don't query the user for authentication for privileged operations. -H, --host Execute the operation remotely. Specify a hostname, or username and hostname separated by @, to connect to. This will use SSH to talk to a remote system. --no-convert If set-keymap or set-x11-keymap is invoked and this option is passed then the keymap will not be converted from the console to X11, or X11 to console, respectively. The following commands are understood: status Show current settings of the system locale and keyboard mapping. set-locale LOCALE. Set the system locale. This takes one or more assignments such as "LANG=de_DE.utf8", "LC_MESSAGES=en_GB.utf8", and so on. See locale(7) for details on the available settings and their meanings. Use list-locales for a list of available locales (see below). list-locales List available locales useful for configuration with set-locale. set-keymap MAP [TOGGLEMAP] Set the system keyboard mapping for the console. This takes a keyboard mapping name (such as "de" or "us"), and possibly a second one to define a toggle keyboard mapping. Unless --no-convert is passed the selected setting is also applied to the default keyboard mapping of X11, after converting it to the closest matching X11 keyboard mapping. Use list-keymaps for a list of available keyboard mappings (see below). list-keymaps List available keyboard mappings for the console, useful for configuration with set-keymap. set-x11-keymap LAYOUT [MODEL] [VARIANT] [OPTIONS] Set the system default keyboard mapping for X11. This takes a keyboard mapping name (such as "de" or "us"), and possibly a model, variant and options, see kbd(4) for details. Unless --no-convert is passed the selected setting is also applied to the system console keyboard mapping, after converting it to the closest matching console keyboard mapping. list-x11-keymap-models, list-x11-keymap-layouts, list-x11-keymap-variants [LAYOUT], list-x11-keymap-options List available X11 keymap models, layouts, variants and options, useful for configuration with set-keymap. The command list-x11-keymap-variants optionally takes a layout parameter to limit the output to the variants suitable for the specific layout.

EXIT STATUS

On success 0 is returned, a non-zero failure code otherwise.

ENVIRONMENT

$SYSTEMD_PAGER Pager to use when --no-pager is not given; overrides $PAGER. Setting this to an empty string or the value cat is equivalent to passing --no-pager.

SEE ALSO

systemd(1), locale(7), locale.conf(5), vconsole.conf(5), loadkeys(1), kbd(4), systemctl(1), systemd-localed.service(8)

© 2019 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.

Читайте также:  Linux sed несколько шаблонов

Источник

How to Change or Set System Locales in Linux

A locale is a set of environmental variables that defines the language, country, and character encoding settings (or any other special variant preferences) for your applications and shell session on a Linux system. These environmental variables are used by system libraries and locale-aware applications on the system.

Locale affects things such as the time/date format, the first day of the week, numbers, currency and many other values formatted in accordance with the language or region/country you set on a Linux system.

In this article, we will show how to view your currently installed system locale and how to set system’s locale in Linux.

How to View System Locale in Linux

To view information about the current installed locale, use the locale or localectl utility.

$ locale LANG=en_US.UTF-8 LANGUAGE=en_US 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= $ localectl status System Locale: LANG=en_US.UTF-8 LANGUAGE=en_US VC Keymap: n/a X11 Layout: us X11 Model: pc105

You can view more information about an environmental variable, for example LC_TIME, which stores the time and date format.

$ locale -k LC_TIME abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat" day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday" abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec" mon="January;February;March;April;May;June;July;August;September;October;November;December" am_pm="AM;PM" d_t_fmt="%a %d %b %Y %r %Z" d_fmt="%m/%d/%Y" t_fmt="%r" t_fmt_ampm="%I:%M:%S %p" era= era_year="" era_d_fmt="" alt_digits= era_d_t_fmt="" era_t_fmt="" time-era-num-entries=0 time-era-entries="S" week-ndays=7 week-1stday=19971130 week-1stweek=1 first_weekday=1 first_workday=2 cal_direction=1 timezone="" date_fmt="%a %b %e %H:%M:%S %Z %Y" time-codeset="UTF-8" alt_mon="January;February;March;April;May;June;July;August;September;October;November;December" ab_alt_mon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"

To display a list of all available locales use the following command.

$ locale -a C C.UTF-8 en_US.utf8 POSIX

How to Set System Locale in Linux

If you want to change or set system local, use the update-locale program. The LANG variable allows you to set the locale for the entire system.

Читайте также:  Linux установка прав chmod

The following command sets LANG to en_IN.UTF-8 and removes definitions for LANGUAGE.

$ sudo update-locale LANG=LANG=en_IN.UTF-8 LANGUAGE OR $ sudo localectl set-locale LANG=en_IN.UTF-8

To configure a specific locale parameter, edit the appropriate variable. For instance.

$ sudo update-locale LC_TIME=en_IN.UTF-8 OR $ sudo localectl set-locale LC_TIME=en_IN.UTF-8

You can find global locale settings in the following files:

  • /etc/default/locale – on Ubuntu/Debian
  • /etc/locale.conf – on CentOS/RHEL

These files can also be edited manually using any of your favorite command line editors such as Vim or Nano, to configure your system locale.

To set a global locale for single user, you can simply open ~/.bash_profile file and add the following lines.

LANG="en_IN.utf8" export LANG

For more information, see the locale, update-locale and localectl man pages.

$ man locale $ man update-locale $ man localectl

That’s all! In this short article, we have explained how to view and set system local in Linux. If you have any questions, use the feedback form below to reach us.

Источник

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