Locale Settings / Time Zone Settings Partial List of Terms
The following is a partial list of the files, terms, and utilities used:
•/etc/timezone
•/etc/localtime
•/usr/share/zoneinfo
•Environment variables:
•LC_*
•LC_ALL
•LANG
•TZ
•/usr/bin/locale
•tzselect
•tzconfig
•date
•iconv
•UTF-8
•ISO-8859
•ASCII
•Unicode
LX0-104 Exam Objectives (M)
Showing posts with label locale settings. Show all posts
Showing posts with label locale settings. Show all posts
Friday, December 9, 2016
Locale Settings V
Locale Settings V
Convert the encoding
iconv
Be aware that if you change the encoding used by the system, you may have trouble viewing
some files correctly if they were created using a different encoding. You can convert the encoding
from one encoding to a new one using the iconv command at the shell prompt.
The syntax is as follows:
iconv –f source_encoding –t destination_encoding –o output_filename input_filename
LX0-104 Exam Objectives (M)
Convert the encoding
iconv
Be aware that if you change the encoding used by the system, you may have trouble viewing
some files correctly if they were created using a different encoding. You can convert the encoding
from one encoding to a new one using the iconv command at the shell prompt.
The syntax is as follows:
iconv –f source_encoding –t destination_encoding –o output_filename input_filename
LX0-104 Exam Objectives (M)
Locale Settings V
Locale Settings V
View all of your current locale settings
To view all of your current locale settings, enter the
/usr/bin/locale
command at the shell prompt. Here is an example:
openSUSE:~ # locale
LANG=POSIX
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL
In this example, only the LANG and the LC_CTYPE variables are actually defined. The other
LC_ variables are automatically populated with the value assigned to LANG.
You can also enter
locale charmap
at the shell prompt to view the type of encoding used.
Here’s an example
openSUSE:~ # locale charmap
UTF-8
ws1:~ #
If you need to localize the system by changing the locale or the encoding, you first must determine what locales have been installed on your system. To do this, use the
–a option
with the locale command to generate a list of all available locales.
You can also use the
–m option
with the locale command to view a list of available encodings.
An example follows:
openSUSE:~ # locale -a
C
POSIX
aa_DJ
aa_DJ.utf8
aa_ER
aa_ER.utf8
....
ws1:~ # locale -m
ANSI_X3.110-1983
ANSI_X3.4-1968
ARMSCII-8
....
LX0-104 Exam Objectives (M)
View all of your current locale settings
To view all of your current locale settings, enter the
/usr/bin/locale
command at the shell prompt. Here is an example:
openSUSE:~ # locale
LANG=POSIX
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL
In this example, only the LANG and the LC_CTYPE variables are actually defined. The other
LC_ variables are automatically populated with the value assigned to LANG.
You can also enter
locale charmap
at the shell prompt to view the type of encoding used.
Here’s an example
openSUSE:~ # locale charmap
UTF-8
ws1:~ #
If you need to localize the system by changing the locale or the encoding, you first must determine what locales have been installed on your system. To do this, use the
–a option
with the locale command to generate a list of all available locales.
You can also use the
–m option
with the locale command to view a list of available encodings.
An example follows:
openSUSE:~ # locale -a
C
POSIX
aa_DJ
aa_DJ.utf8
aa_ER
aa_ER.utf8
....
ws1:~ # locale -m
ANSI_X3.110-1983
ANSI_X3.4-1968
ARMSCII-8
....
LX0-104 Exam Objectives (M)
Locale Settings IV
Locale Settings IV
Set locale other than the default
If for some reason you need to localize a Linux system to a locale other than the default that
was configured at installation, you simply change the value of the appropriate environment variable.
Generally, all of these variables will be set to the same value (or the LC_ALL or LANG variable
will be used to specify the default locale for all variables). However, if necessary, you can also
set them independently to different values.
If you do this, however, be aware that not all of the LC_ variables have the same level of precedence.
Linux uses the following rules to determine which locale setting to use:
1. If the LC_ALL variable is defined, its value is used and the values assigned to all other
LC_ variables are not checked.
2. If LC_ALL is undefined, the specific LC_ variable in question is checked. If the specific
LC_ variable has a value, it is used.
3. If the LC_ variable in question has a null value, the LANG environment variable is used.
If you want all of your LC_ variables to use the same value, you can set the LC_ALL variable,
thus eliminating the need to set each individual variable. However, if you want to use different
values for your LC_ variables, you must first set LC_ALL to a null value. In fact, many distributions
leave LC_ALL undefined for this very reason. Instead, they set the value of LC_CTYPE to
define the default encoding and the value of LANG to provide a default value to all of your other
LC_ variables. However, because LANG is third in priority, you can manually set the value of an
LC_ variable without impacting any other LC_ variables.
LX0-104 Exam Objectives (M)
Set locale other than the default
If for some reason you need to localize a Linux system to a locale other than the default that
was configured at installation, you simply change the value of the appropriate environment variable.
Generally, all of these variables will be set to the same value (or the LC_ALL or LANG variable
will be used to specify the default locale for all variables). However, if necessary, you can also
set them independently to different values.
If you do this, however, be aware that not all of the LC_ variables have the same level of precedence.
Linux uses the following rules to determine which locale setting to use:
1. If the LC_ALL variable is defined, its value is used and the values assigned to all other
LC_ variables are not checked.
2. If LC_ALL is undefined, the specific LC_ variable in question is checked. If the specific
LC_ variable has a value, it is used.
3. If the LC_ variable in question has a null value, the LANG environment variable is used.
If you want all of your LC_ variables to use the same value, you can set the LC_ALL variable,
thus eliminating the need to set each individual variable. However, if you want to use different
values for your LC_ variables, you must first set LC_ALL to a null value. In fact, many distributions
leave LC_ALL undefined for this very reason. Instead, they set the value of LC_CTYPE to
define the default encoding and the value of LANG to provide a default value to all of your other
LC_ variables. However, because LANG is third in priority, you can manually set the value of an
LC_ variable without impacting any other LC_ variables.
LX0-104 Exam Objectives (M)
Locale Settings III
Locale Settings III
Locale settings were automatically defined for you based on your selections during the installation process
When you installed your Linux system, your locale settings were automatically defined for you
based on your selections during the installation process. To view them at the shell prompt, you
can use the echo command. Here is an example:
openSUSE:~ # echo $LC_CTYPE
en_US.UTF-8
openSUSE:~ #
As you can see in this example, the LC_CYTPE variable was populated on this system during
installation. This variable defines the default character type and encoding used on the system. As
you can see, this system uses a locale of U.S. English with Unicode text encoding.
Just as an aside, you can also use a locale named C. This locale is very useful if you create a lot
of shell scripts at the shell prompt. It configures the following default locale settings:
• ASCII encoding
• POSIX character classes
• U.S. English time, date, number, and currency formats
LX0-104 Exam Objectives (M)
Locale settings were automatically defined for you based on your selections during the installation process
When you installed your Linux system, your locale settings were automatically defined for you
based on your selections during the installation process. To view them at the shell prompt, you
can use the echo command. Here is an example:
openSUSE:~ # echo $LC_CTYPE
en_US.UTF-8
openSUSE:~ #
As you can see in this example, the LC_CYTPE variable was populated on this system during
installation. This variable defines the default character type and encoding used on the system. As
you can see, this system uses a locale of U.S. English with Unicode text encoding.
Just as an aside, you can also use a locale named C. This locale is very useful if you create a lot
of shell scripts at the shell prompt. It configures the following default locale settings:
• ASCII encoding
• POSIX character classes
• U.S. English time, date, number, and currency formats
LX0-104 Exam Objectives (M)
Locale Settings II
Locale Settings II
LC_CTYPE locale variable
The LC_CTYPE locale variable can be assigned a locale value using the following syntax:
language_territory.codeset @modifier
This syntax uses these values:
• language
Specifies the ISO 639 language code to be used (specified in lowercase)
• territory
Specifies the ISO 3166 country code to be used (specified in uppercase)
• codeset
Specifies the character set to be used
• modifier
Specifies other locale attributes, such as dialect or currency
Consider the following examples:
• en_US
The language and territory for English in the United States
• en_CA
The language and territory for English in Canada
• fr_CA
The language and territory for French Canadian
You can also specify an encoding in the locale. For example, you could use
en_US.UTF-8
to configure a default locale of U.S. English using UTF-8 character encoding (also known as
Unicode encoding).
LX0-104 Exam Objectives (M)
LC_CTYPE locale variable
The LC_CTYPE locale variable can be assigned a locale value using the following syntax:
language_territory.codeset @modifier
This syntax uses these values:
• language
Specifies the ISO 639 language code to be used (specified in lowercase)
• territory
Specifies the ISO 3166 country code to be used (specified in uppercase)
• codeset
Specifies the character set to be used
• modifier
Specifies other locale attributes, such as dialect or currency
Consider the following examples:
• en_US
The language and territory for English in the United States
• en_CA
The language and territory for English in Canada
• fr_CA
The language and territory for French Canadian
You can also specify an encoding in the locale. For example, you could use
en_US.UTF-8
to configure a default locale of U.S. English using UTF-8 character encoding (also known as
Unicode encoding).
LX0-104 Exam Objectives (M)
Locale Settings I
Locale Settings I
Configuring Locale Settings
When you install a Linux system, you typically configure the system’s
locale during the installation process. The system’s locale determines the following:
• The language and encoding of text displayed on the screen
• Your character classes
• The default sort order
• The default number format
• The default currency format
• How the date and time are displayed
Your locale settings are determined by the values assigned to the following environment variables:
• LC_CTYPE
Configures the default character type and encoding
• LC_MESSAGES
Configures natural language messages
• LC_COLLATE
Configures your sorting rules
• LC_NUMERIC
Configures your number format
• LC_MONETARY
Configures your currency format
• LC_TIME
Configures the date and time display
• LC_PAPER
Configures your default paper size
• LC_NAME
Configures the default personal name format
• LC_ADDRESS
Configures the default address format
• LC_TELEPHONE
Configures the default telephone number format
• LC_MEASUREMENT
Configures the default measurement unit
• LC_ALL
Overrides all other LC_ environment variables
• LANG
Specifies the default locale value for all LC_ variables
• LANGUAGE
Overrides LC_MESSAGES
LX0-104 Exam Objectives (M)
Configuring Locale Settings
When you install a Linux system, you typically configure the system’s
locale during the installation process. The system’s locale determines the following:
• The language and encoding of text displayed on the screen
• Your character classes
• The default sort order
• The default number format
• The default currency format
• How the date and time are displayed
Your locale settings are determined by the values assigned to the following environment variables:
• LC_CTYPE
Configures the default character type and encoding
• LC_MESSAGES
Configures natural language messages
• LC_COLLATE
Configures your sorting rules
• LC_NUMERIC
Configures your number format
• LC_MONETARY
Configures your currency format
• LC_TIME
Configures the date and time display
• LC_PAPER
Configures your default paper size
• LC_NAME
Configures the default personal name format
• LC_ADDRESS
Configures the default address format
• LC_TELEPHONE
Configures the default telephone number format
• LC_MEASUREMENT
Configures the default measurement unit
• LC_ALL
Overrides all other LC_ environment variables
• LANG
Specifies the default locale value for all LC_ variables
• LANGUAGE
Overrides LC_MESSAGES
LX0-104 Exam Objectives (M)
Subscribe to:
Posts (Atom)