In this lesson,
you're going to learn about localization options
and how users can become more comfortable
working in their Linux environment
by localizing their system according to the specific region
or culture they belong to.
We're going to primarily discuss
the way to achieve these different localization options
to be able to fit a user's needs.
Now, in the world of operating systems,
localization is considered the process
of adapting system components
for use within a distinct culture
other than the culture that the system
was originally designed for.
Now, in a practical sense,
this usually means translating interface components
into specific languages.
Converting measurements into the system used
in a specific region.
Configuring the keyboard layout
to one that works more with what the user is familiar with
or setting the date and time attributes
to a specific location.
Localizing a Linux system is important for organizations
that provide Linux services to personnel and customers
all over the world.
An administrator in Japan, for example,
is likely going to be more comfortable
working on a Linux server if that server is localized
to use the Japanese language,
rather than having to use the English language.
Working with the local time and with a compatible keyboard
also enhances the user experience
for our international users.
Typically, you're going to set the timezone
during the installation of the operating system,
but you can also change it easily at any time later on.
Using the correct timezone is really essential
for many system-related tasks and processes.
For example, the cron daemon is going to use
the system's timezone for executing cron jobs,
which are automated tasks
that you're going to perform in the background
or at certain times of the day.
The timezone is also going to be used for your logs,
including the timestamps within those logs.
The /usr/share/zoneinfo directory
is a container for all the regional timezones
that you can configure for the system to use.
Sub-directories in this container
also organize languages by region.
For example, the Africa sub-directory
will include the timezone files
for specific countries or cities
within the African continent.
One way to change the system's timezone
is by creating a symbolic link
to one of these individual timezone files
to the /etc/localtime file.
In some Debian-based distros though.
You'll find this located in /etc/timezone instead,
and this can be used to view the timezone.
This text file will list the timezone
by the region structure you're going to see
in the /usr/share/zoneinfo directory.
For example, the file might include the text Europe/Berlin
to indicate that the system is using that timezone
and the city that it's in.
In this case, European time in the city of Berlin, Germany.
The date command is going to be used to print the date
in a specified format,
and the date command will print that date
based upon the /etc/localtime file.
By default, it's going to print the date
in the following format:
The day of the week, the month, the day
and the 24 hour time located as
number, number, colon, number, number,
colon, number, number,
and then the timezone and the year.
For example, it might say Wednesday, Oct 31,
15:03:16, GMT, 2018.
You can also format the time
using a number of different formatting options if you like.
You can initialize the formatting options with a plus sign
and each option is prefaced with a percent sign.
For example, to retrieve the week number out of 52 weeks
in a year, you would enter date plus percent V.
You could also use the date command
to change the system's date by including the -S option
to set it and provide an argument with it.
The syntax of the date command is going to be
date, options and format.
There are going to be several formatting options available.
For example, if you use percent A
you're going to print the full weekday name
like Monday, Tuesday, Wednesday.
If you use percent B,
this'll print the full month name
like January, February, or March.
If you use percent F, you'll print out the date
in yyyy-mm-dd format.
Or something like 2021-10-31.
If you use percent H,
you'll print the hour in the 24-hour format,
which is what is commonly used in Europe,
but not commonly used in America.
If you use percent I,
you'll print the hour in 12-hour format
which is much more commonly used in the United States.
If you use percent J, you'll print the day of the year.
If you use percent S,
you'll print out the date in seconds.
If you use percent V,
you'll print out the week of the year.
And if you use percent lowercase x,
you're going to print the date representation
based on your locale.
Whereas if you use percent X
you'll print out the time representation
based on the locale.
And if you use percent Y, you'll print out the year.
Another command we want to talk about is time date control,
which is written as timedatectl.
This is going to be used to set the system
date and time information
and it can take one of several sub-commands.
The status sub-command is going to be used
to show the current date and time information,
including the local time, the universal time, RTC time,
the timezone, and more.
This is the same as issuing the timedatectl command
all by itself.
If you use the set-time sub-command
you're going to be able to set the system's time
using the time you provide.
Your format should be in the year-month-day.
And then the hour, minutes and seconds format.
The set-timezone sub-command
is going to be used to set the systems' timezone
to the timezone you tell it.
The zone in the format is going to be written as
/usr/share/zoneinformation as its structure.
The list-timezones is a sub-command that's going to list out
all the available timezones in the format specified
by the /usr/share/zone infrastructure.
While set-ntp with the bracket 0 or 1,
is going to be used to enable or disable the synchronization
with a network time protocol server or NTP server.
To run the time date control command,
simply type in timedatectl,
the options and the sub-command you want to use.
The time date control command
has a lot of different options as well.
This includes things like -H and remote host
which allows you to execute the operation
on a remote host specified by a hostname or IP address.
The --no-ask-password option,
is going to prevent the user from being asked to authenticate
when performing a privileged task.
The --adjust-system-clock option,
is going to synchronize your local or system clock
based on the hardware clock,
when you're setting up the hardware clock.
The -M local container option,
is going to execute the operation on a local container.
The time date control command is going to expose
three different clocks that the system uses
and you can get information about them.
The local clock will reflect the current time
in the system's locale.
The universal time clock is going to represent the time
irrespective of your local timezone.
It's going to use international standard coordinated
universal time known as UTC.
And this is the same as GMT time, or Greenwich meantime.
On the other hand, the hardware clock functions
at the hardware level,
and it's going to keep time even when the computer
is powered off, because of a battery on the motherboard.
When you use the time date control command,
it's possible to set the hardware clock
to be equal to your local time.
However, this is not advisable,
because the RTC is not automatically updated.
It's only going to be updated by external facilities
like other installed operating systems.
Multiple operating systems can all adjust the RTC
for daylight savings time, known as DST.
And this can actually cause an overcorrection.
The hardware clock command or hwclock
will enable you to view and set the hardware clock itself.
As mentioned before, it's strongly recommended
that you keep the hardware clock aligned with UTC
to prevent overcorrection by other operating systems.
You can also use the hardware clock command
to adjust the systematic drift.
Now the systematic drift is the predictable amount of time
that the hardware clock gains or loses each day,
making it inaccurate and throwing it out of alignment
with the system clock.
The /etc/adjtime
is a file that records information
about when and by how much the hardware clock
is being changed.
To run the hardware clock command,
simply type in hwclock and the options.
Some options for the hardware clock command
are things like -set, which is going to be used
to set the hardware clock to the provided date and time.
The -u option is used to set the hardware clock to UTC time.
And the -s option is going to be used to set the system time
from the hardware clock.
If you use the -adjust option
you're going to be able to add or subtract time
from the hardware clock to account for systematic drift.
The locale control command, or localectl command
is going to be used to view and configure the system locale
and keyboard layout settings.
A system locale is going to determine how it's going to represent
various cultural elements, most specifically,
the language used in the interface.
Like the time date control command,
the locale control command
is going to have various sub-commands
for managing the system locale and the keyboard layout.
The status sub-command is going to be used
for the current locale and keyboard layout.
This is the same thing as issuing
the locale control command by itself.
If you use the set-locale sub-command
it's going to set the system locale to the locale you provide.
If you use the list-locale sub-command,
it's going to list out all the available locales
on that system.
The set-keymap sub-command is going to set the keyboard layout
to the one you provide.
And finally, the list-keymaps command
is going to be used to list all the keyboard layouts
on the system.
To run the locale control command,
type in localectl space, the options space
and the sub-command.
Now, some of the options for this command
include -H and the remote host.
This option is going to execute the operation
on a remote host that you specify using a hostname
or IP address.
-no-ask-password option
is going to be used to prevent the user
from being asked to authenticate
when they try to perform a privileged task.
The --no-pager option is going to be used
to prevent the output from being piped
into a paging utility.
And the --no-convert option
is going to be used to prevent a keymap change
from the console, that's going to be applied to
an X display server and vice versa.
For example, if you're in the console,
you only want to change the console.
If you're in the graphical environment,
you only want to change the graphical environment.
Now the character encoding
is the process of converting text into bytes.
And decoding is the process of converting bytes
back into text.
Both of these concepts are really important,
because text is much easier for us as humans
to interact with, but computers
like to process our data in bytes.
In many systems, the default encoding
is going to be set to UTF-8.
And this is a Unicode character set.
For example, the letter C
is associated with the position number of U plus 0043
inside the UTF-8 standard or Unicode.
In Linux, the locale settings
will determine what encoding scheme is going to be used
by your system.
The same general locale
may have many different encoding options though,
such as ASCII or UTF-8.
Let's say, for example, you're looking in Germany
de underscore DE.utf8
and de underscore DE.iso88591
are both set for German and the German language,
but these sets
are actually two different encoding standards.
One is for UTF-8 and the other is for ASCII.