The Linux local command works with the environmental variables that define the internationalization of the system, such as characters, dates, and numbering.
Linux maintains a list of environmental variables to define the internationalization standards of language, number format, time format, date format, currency format, among others.
The variables are:
The locale command reports these environmental variables.
$ locale
lang=pt_BR.UTF-8
LANGUAGE=
lc_ctype="pt_br.utf-8"
lc_numeric="pt_br.utf-8"
lc_time="pt_br.utf-8" lc_br.utf-8" lc_br.utf-8"
lc_monetary="pt_br.utf-8" lc_messages="pt_br.utf-8" lc_br.utf-8"
lc_br.utf-8" lc_br.utf-8"
lc_messages="pt_br.utf-8" lc_br.utf-8"
lc_br.utf-8" UTF-8" LC_NAME="en_BR.UTF-8"
LC_ADDRESS="en_BR.UTF-8"
LC_TELEPHONE=”PT_BR.UTF-8″
LC_MEASUREMENT=”PT_BR.UTF-8″
LC_IDENTIFICATION=”PT_BR.UTF-8″
LC_ALL=pt_BR.UTF-8
The LC_ALL variable can be used to configure all the others.
The “-a” option provides the list of possible locations:
$ local -a en_US.utf8 pt_BR.utf8
The desired location may not always be available in the system. If it does not appear with the “-a” option in the locale command, it is necessary to generate the location.
To see the list of all locations that can be generated, check the contents of the /etc/locale.gen file:
$ cat /etc/locale.gen # AA_Dj ISO-8859-1 # AA_dj.UTF-8 UTF-8 # AA_er UTF-8 (...)
To generate the desired location and be able to use it in the LC_ALL variable, the locale-gen command is used to generate the location:
$ locale-gen pt_BR.UTF-8
Generating locals (this might take a while)...
pt_BR.UTF-8... done
Generation complete.
To change the location setting, simply change the LC_ALL variable:
$ export LC_ALL=en_BR.UTF-8
Since the location is configured by environment variables, they must be in the shell load script or in the profile for them to be permanent in the system.
The systemd localectl service can be used to query and change the system’s location and keyboard layout settings.
This service can be used to control the language settings of the system services and the user interface before the user logs in.
Example:
To view the configured location:
$ localectl status System Locale: lang=en_US.UTF-8 VC Keymap: n/a X11 Layout: n/a
To change the location:
$ sudo localectl set-locale lc_time=EN_IN.UTF-8
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.