1
00:00:00,120 --> 00:00:01,110
In this lesson,

2
00:00:01,110 --> 00:00:03,930
you're going to learn about localization options

3
00:00:03,930 --> 00:00:05,970
and how users can become more comfortable

4
00:00:05,970 --> 00:00:07,890
working in their Linux environment

5
00:00:07,890 --> 00:00:11,040
by localizing their system according to the specific region

6
00:00:11,040 --> 00:00:13,050
or culture they belong to.

7
00:00:13,050 --> 00:00:14,520
We're going to primarily discuss

8
00:00:14,520 --> 00:00:17,280
the way to achieve these different localization options

9
00:00:17,280 --> 00:00:19,590
to be able to fit a user's needs.

10
00:00:19,590 --> 00:00:21,660
Now, in the world of operating systems,

11
00:00:21,660 --> 00:00:23,760
localization is considered the process

12
00:00:23,760 --> 00:00:25,530
of adapting system components

13
00:00:25,530 --> 00:00:27,660
for use within a distinct culture

14
00:00:27,660 --> 00:00:29,340
other than the culture that the system

15
00:00:29,340 --> 00:00:31,230
was originally designed for.

16
00:00:31,230 --> 00:00:32,910
Now, in a practical sense,

17
00:00:32,910 --> 00:00:35,940
this usually means translating interface components

18
00:00:35,940 --> 00:00:37,650
into specific languages.

19
00:00:37,650 --> 00:00:39,720
Converting measurements into the system used

20
00:00:39,720 --> 00:00:41,310
in a specific region.

21
00:00:41,310 --> 00:00:42,870
Configuring the keyboard layout

22
00:00:42,870 --> 00:00:45,990
to one that works more with what the user is familiar with

23
00:00:45,990 --> 00:00:47,970
or setting the date and time attributes

24
00:00:47,970 --> 00:00:49,830
to a specific location.

25
00:00:49,830 --> 00:00:53,040
Localizing a Linux system is important for organizations

26
00:00:53,040 --> 00:00:55,770
that provide Linux services to personnel and customers

27
00:00:55,770 --> 00:00:57,240
all over the world.

28
00:00:57,240 --> 00:00:59,310
An administrator in Japan, for example,

29
00:00:59,310 --> 00:01:00,990
is likely going to be more comfortable

30
00:01:00,990 --> 00:01:04,290
working on a Linux server if that server is localized

31
00:01:04,290 --> 00:01:05,820
to use the Japanese language,

32
00:01:05,820 --> 00:01:08,610
rather than having to use the English language.

33
00:01:08,610 --> 00:01:11,520
Working with the local time and with a compatible keyboard

34
00:01:11,520 --> 00:01:13,440
also enhances the user experience

35
00:01:13,440 --> 00:01:15,660
for our international users.

36
00:01:15,660 --> 00:01:17,790
Typically, you're going to set the timezone

37
00:01:17,790 --> 00:01:20,430
during the installation of the operating system,

38
00:01:20,430 --> 00:01:24,090
but you can also change it easily at any time later on.

39
00:01:24,090 --> 00:01:26,580
Using the correct timezone is really essential

40
00:01:26,580 --> 00:01:29,490
for many system-related tasks and processes.

41
00:01:29,490 --> 00:01:32,130
For example, the cron daemon is going to use

42
00:01:32,130 --> 00:01:35,250
the system's timezone for executing cron jobs,

43
00:01:35,250 --> 00:01:36,450
which are automated tasks

44
00:01:36,450 --> 00:01:38,280
that you're going to perform in the background

45
00:01:38,280 --> 00:01:40,530
or at certain times of the day.

46
00:01:40,530 --> 00:01:43,410
The timezone is also going to be used for your logs,

47
00:01:43,410 --> 00:01:46,530
including the timestamps within those logs.

48
00:01:46,530 --> 00:01:50,430
The /usr/share/zoneinfo directory

49
00:01:50,430 --> 00:01:53,010
is a container for all the regional timezones

50
00:01:53,010 --> 00:01:55,950
that you can configure for the system to use.

51
00:01:55,950 --> 00:01:57,510
Sub-directories in this container

52
00:01:57,510 --> 00:02:00,000
also organize languages by region.

53
00:02:00,000 --> 00:02:02,430
For example, the Africa sub-directory

54
00:02:02,430 --> 00:02:03,930
will include the timezone files

55
00:02:03,930 --> 00:02:05,820
for specific countries or cities

56
00:02:05,820 --> 00:02:08,009
within the African continent.

57
00:02:08,009 --> 00:02:10,110
One way to change the system's timezone

58
00:02:10,110 --> 00:02:11,820
is by creating a symbolic link

59
00:02:11,820 --> 00:02:14,430
to one of these individual timezone files

60
00:02:14,430 --> 00:02:18,210
to the /etc/localtime file.

61
00:02:18,210 --> 00:02:20,310
In some Debian-based distros though.

62
00:02:20,310 --> 00:02:24,420
You'll find this located in /etc/timezone instead,

63
00:02:24,420 --> 00:02:26,760
and this can be used to view the timezone.

64
00:02:26,760 --> 00:02:28,860
This text file will list the timezone

65
00:02:28,860 --> 00:02:30,870
by the region structure you're going to see

66
00:02:30,870 --> 00:02:35,640
in the /usr/share/zoneinfo directory.

67
00:02:35,640 --> 00:02:40,380
For example, the file might include the text Europe/Berlin

68
00:02:40,380 --> 00:02:43,800
to indicate that the system is using that timezone

69
00:02:43,800 --> 00:02:44,970
and the city that it's in.

70
00:02:44,970 --> 00:02:49,530
In this case, European time in the city of Berlin, Germany.

71
00:02:49,530 --> 00:02:52,140
The date command is going to be used to print the date

72
00:02:52,140 --> 00:02:53,760
in a specified format,

73
00:02:53,760 --> 00:02:56,130
and the date command will print that date

74
00:02:56,130 --> 00:03:00,600
based upon the /etc/localtime file.

75
00:03:00,600 --> 00:03:02,640
By default, it's going to print the date

76
00:03:02,640 --> 00:03:04,350
in the following format:

77
00:03:04,350 --> 00:03:07,590
The day of the week, the month, the day

78
00:03:07,590 --> 00:03:10,290
and the 24 hour time located as

79
00:03:10,290 --> 00:03:12,360
number, number, colon, number, number,

80
00:03:12,360 --> 00:03:13,920
colon, number, number,

81
00:03:13,920 --> 00:03:16,350
and then the timezone and the year.

82
00:03:16,350 --> 00:03:20,610
For example, it might say Wednesday, Oct 31,

83
00:03:20,610 --> 00:03:25,610
15:03:16, GMT, 2018.

84
00:03:25,680 --> 00:03:27,300
You can also format the time

85
00:03:27,300 --> 00:03:30,480
using a number of different formatting options if you like.

86
00:03:30,480 --> 00:03:33,870
You can initialize the formatting options with a plus sign

87
00:03:33,870 --> 00:03:37,170
and each option is prefaced with a percent sign.

88
00:03:37,170 --> 00:03:40,620
For example, to retrieve the week number out of 52 weeks

89
00:03:40,620 --> 00:03:45,620
in a year, you would enter date plus percent V.

90
00:03:45,810 --> 00:03:47,610
You could also use the date command

91
00:03:47,610 --> 00:03:51,030
to change the system's date by including the -S option

92
00:03:51,030 --> 00:03:53,700
to set it and provide an argument with it.

93
00:03:53,700 --> 00:03:55,830
The syntax of the date command is going to be

94
00:03:55,830 --> 00:03:58,800
date, options and format.

95
00:03:58,800 --> 00:04:01,500
There are going to be several formatting options available.

96
00:04:01,500 --> 00:04:04,530
For example, if you use percent A

97
00:04:04,530 --> 00:04:06,660
you're going to print the full weekday name

98
00:04:06,660 --> 00:04:09,480
like Monday, Tuesday, Wednesday.

99
00:04:09,480 --> 00:04:11,520
If you use percent B,

100
00:04:11,520 --> 00:04:13,260
this'll print the full month name

101
00:04:13,260 --> 00:04:16,320
like January, February, or March.

102
00:04:16,320 --> 00:04:19,769
If you use percent F, you'll print out the date

103
00:04:19,769 --> 00:04:23,087
in yyyy-mm-dd format.

104
00:04:25,350 --> 00:04:30,350
Or something like 2021-10-31.

105
00:04:30,720 --> 00:04:32,790
If you use percent H,

106
00:04:32,790 --> 00:04:35,670
you'll print the hour in the 24-hour format,

107
00:04:35,670 --> 00:04:37,680
which is what is commonly used in Europe,

108
00:04:37,680 --> 00:04:40,350
but not commonly used in America.

109
00:04:40,350 --> 00:04:41,613
If you use percent I,

110
00:04:42,450 --> 00:04:44,730
you'll print the hour in 12-hour format

111
00:04:44,730 --> 00:04:48,300
which is much more commonly used in the United States.

112
00:04:48,300 --> 00:04:52,020
If you use percent J, you'll print the day of the year.

113
00:04:52,020 --> 00:04:53,970
If you use percent S,

114
00:04:53,970 --> 00:04:56,460
you'll print out the date in seconds.

115
00:04:56,460 --> 00:04:58,530
If you use percent V,

116
00:04:58,530 --> 00:05:00,750
you'll print out the week of the year.

117
00:05:00,750 --> 00:05:03,180
And if you use percent lowercase x,

118
00:05:03,180 --> 00:05:05,100
you're going to print the date representation

119
00:05:05,100 --> 00:05:06,237
based on your locale.

120
00:05:06,237 --> 00:05:08,880
Whereas if you use percent X

121
00:05:08,880 --> 00:05:11,070
you'll print out the time representation

122
00:05:11,070 --> 00:05:12,510
based on the locale.

123
00:05:12,510 --> 00:05:16,590
And if you use percent Y, you'll print out the year.

124
00:05:16,590 --> 00:05:20,700
Another command we want to talk about is time date control,

125
00:05:20,700 --> 00:05:22,663
which is written as timedatectl.

126
00:05:24,270 --> 00:05:26,130
This is going to be used to set the system

127
00:05:26,130 --> 00:05:27,960
date and time information

128
00:05:27,960 --> 00:05:30,990
and it can take one of several sub-commands.

129
00:05:30,990 --> 00:05:33,390
The status sub-command is going to be used

130
00:05:33,390 --> 00:05:35,700
to show the current date and time information,

131
00:05:35,700 --> 00:05:39,717
including the local time, the universal time, RTC time,

132
00:05:39,717 --> 00:05:41,910
the timezone, and more.

133
00:05:41,910 --> 00:05:45,030
This is the same as issuing the timedatectl command

134
00:05:45,030 --> 00:05:46,740
all by itself.

135
00:05:46,740 --> 00:05:49,470
If you use the set-time sub-command

136
00:05:49,470 --> 00:05:51,510
you're going to be able to set the system's time

137
00:05:51,510 --> 00:05:53,340
using the time you provide.

138
00:05:53,340 --> 00:05:57,870
Your format should be in the year-month-day.

139
00:05:57,870 --> 00:06:01,710
And then the hour, minutes and seconds format.

140
00:06:01,710 --> 00:06:03,990
The set-timezone sub-command

141
00:06:03,990 --> 00:06:06,480
is going to be used to set the systems' timezone

142
00:06:06,480 --> 00:06:08,250
to the timezone you tell it.

143
00:06:08,250 --> 00:06:10,494
The zone in the format is going to be written as

144
00:06:10,494 --> 00:06:15,494
/usr/share/zoneinformation as its structure.

145
00:06:15,990 --> 00:06:19,230
The list-timezones is a sub-command that's going to list out

146
00:06:19,230 --> 00:06:22,440
all the available timezones in the format specified

147
00:06:22,440 --> 00:06:26,700
by the /usr/share/zone infrastructure.

148
00:06:26,700 --> 00:06:31,700
While set-ntp with the bracket 0 or 1,

149
00:06:32,370 --> 00:06:36,090
is going to be used to enable or disable the synchronization

150
00:06:36,090 --> 00:06:40,500
with a network time protocol server or NTP server.

151
00:06:40,500 --> 00:06:42,720
To run the time date control command,

152
00:06:42,720 --> 00:06:45,630
simply type in timedatectl,

153
00:06:45,630 --> 00:06:48,690
the options and the sub-command you want to use.

154
00:06:48,690 --> 00:06:50,130
The time date control command

155
00:06:50,130 --> 00:06:52,500
has a lot of different options as well.

156
00:06:52,500 --> 00:06:56,310
This includes things like -H and remote host

157
00:06:56,310 --> 00:06:58,290
which allows you to execute the operation

158
00:06:58,290 --> 00:07:02,789
on a remote host specified by a hostname or IP address.

159
00:07:02,789 --> 00:07:05,700
The --no-ask-password option,

160
00:07:05,700 --> 00:07:08,460
is going to prevent the user from being asked to authenticate

161
00:07:08,460 --> 00:07:10,830
when performing a privileged task.

162
00:07:10,830 --> 00:07:13,710
The --adjust-system-clock option,

163
00:07:13,710 --> 00:07:16,530
is going to synchronize your local or system clock

164
00:07:16,530 --> 00:07:18,030
based on the hardware clock,

165
00:07:18,030 --> 00:07:20,280
when you're setting up the hardware clock.

166
00:07:20,280 --> 00:07:23,340
The -M local container option,

167
00:07:23,340 --> 00:07:27,030
is going to execute the operation on a local container.

168
00:07:27,030 --> 00:07:29,370
The time date control command is going to expose

169
00:07:29,370 --> 00:07:31,890
three different clocks that the system uses

170
00:07:31,890 --> 00:07:34,050
and you can get information about them.

171
00:07:34,050 --> 00:07:36,480
The local clock will reflect the current time

172
00:07:36,480 --> 00:07:38,280
in the system's locale.

173
00:07:38,280 --> 00:07:41,430
The universal time clock is going to represent the time

174
00:07:41,430 --> 00:07:44,220
irrespective of your local timezone.

175
00:07:44,220 --> 00:07:46,920
It's going to use international standard coordinated

176
00:07:46,920 --> 00:07:49,830
universal time known as UTC.

177
00:07:49,830 --> 00:07:54,390
And this is the same as GMT time, or Greenwich meantime.

178
00:07:54,390 --> 00:07:56,820
On the other hand, the hardware clock functions

179
00:07:56,820 --> 00:07:58,050
at the hardware level,

180
00:07:58,050 --> 00:08:00,000
and it's going to keep time even when the computer

181
00:08:00,000 --> 00:08:03,540
is powered off, because of a battery on the motherboard.

182
00:08:03,540 --> 00:08:05,970
When you use the time date control command,

183
00:08:05,970 --> 00:08:08,040
it's possible to set the hardware clock

184
00:08:08,040 --> 00:08:09,960
to be equal to your local time.

185
00:08:09,960 --> 00:08:12,270
However, this is not advisable,

186
00:08:12,270 --> 00:08:15,690
because the RTC is not automatically updated.

187
00:08:15,690 --> 00:08:18,450
It's only going to be updated by external facilities

188
00:08:18,450 --> 00:08:20,850
like other installed operating systems.

189
00:08:20,850 --> 00:08:24,150
Multiple operating systems can all adjust the RTC

190
00:08:24,150 --> 00:08:27,090
for daylight savings time, known as DST.

191
00:08:27,090 --> 00:08:29,850
And this can actually cause an overcorrection.

192
00:08:29,850 --> 00:08:32,909
The hardware clock command or hwclock

193
00:08:32,909 --> 00:08:36,330
will enable you to view and set the hardware clock itself.

194
00:08:36,330 --> 00:08:38,909
As mentioned before, it's strongly recommended

195
00:08:38,909 --> 00:08:42,030
that you keep the hardware clock aligned with UTC

196
00:08:42,030 --> 00:08:45,360
to prevent overcorrection by other operating systems.

197
00:08:45,360 --> 00:08:47,490
You can also use the hardware clock command

198
00:08:47,490 --> 00:08:49,680
to adjust the systematic drift.

199
00:08:49,680 --> 00:08:52,830
Now the systematic drift is the predictable amount of time

200
00:08:52,830 --> 00:08:55,770
that the hardware clock gains or loses each day,

201
00:08:55,770 --> 00:08:58,560
making it inaccurate and throwing it out of alignment

202
00:08:58,560 --> 00:09:00,450
with the system clock.

203
00:09:00,450 --> 00:09:03,540
The /etc/adjtime

204
00:09:03,540 --> 00:09:05,400
is a file that records information

205
00:09:05,400 --> 00:09:08,310
about when and by how much the hardware clock

206
00:09:08,310 --> 00:09:09,810
is being changed.

207
00:09:09,810 --> 00:09:11,640
To run the hardware clock command,

208
00:09:11,640 --> 00:09:15,420
simply type in hwclock and the options.

209
00:09:15,420 --> 00:09:17,550
Some options for the hardware clock command

210
00:09:17,550 --> 00:09:20,220
are things like -set, which is going to be used

211
00:09:20,220 --> 00:09:23,520
to set the hardware clock to the provided date and time.

212
00:09:23,520 --> 00:09:28,197
The -u option is used to set the hardware clock to UTC time.

213
00:09:28,197 --> 00:09:31,890
And the -s option is going to be used to set the system time

214
00:09:31,890 --> 00:09:33,720
from the hardware clock.

215
00:09:33,720 --> 00:09:35,940
If you use the -adjust option

216
00:09:35,940 --> 00:09:37,860
you're going to be able to add or subtract time

217
00:09:37,860 --> 00:09:41,133
from the hardware clock to account for systematic drift.

218
00:09:41,970 --> 00:09:46,970
The locale control command, or localectl command

219
00:09:47,520 --> 00:09:50,550
is going to be used to view and configure the system locale

220
00:09:50,550 --> 00:09:52,500
and keyboard layout settings.

221
00:09:52,500 --> 00:09:55,410
A system locale is going to determine how it's going to represent

222
00:09:55,410 --> 00:09:58,260
various cultural elements, most specifically,

223
00:09:58,260 --> 00:10:00,780
the language used in the interface.

224
00:10:00,780 --> 00:10:02,880
Like the time date control command,

225
00:10:02,880 --> 00:10:04,220
the locale control command

226
00:10:04,220 --> 00:10:06,180
is going to have various sub-commands

227
00:10:06,180 --> 00:10:09,450
for managing the system locale and the keyboard layout.

228
00:10:09,450 --> 00:10:12,030
The status sub-command is going to be used

229
00:10:12,030 --> 00:10:14,910
for the current locale and keyboard layout.

230
00:10:14,910 --> 00:10:16,320
This is the same thing as issuing

231
00:10:16,320 --> 00:10:19,140
the locale control command by itself.

232
00:10:19,140 --> 00:10:21,480
If you use the set-locale sub-command

233
00:10:21,480 --> 00:10:24,960
it's going to set the system locale to the locale you provide.

234
00:10:24,960 --> 00:10:27,330
If you use the list-locale sub-command,

235
00:10:27,330 --> 00:10:29,700
it's going to list out all the available locales

236
00:10:29,700 --> 00:10:31,260
on that system.

237
00:10:31,260 --> 00:10:34,620
The set-keymap sub-command is going to set the keyboard layout

238
00:10:34,620 --> 00:10:36,210
to the one you provide.

239
00:10:36,210 --> 00:10:38,760
And finally, the list-keymaps command

240
00:10:38,760 --> 00:10:41,130
is going to be used to list all the keyboard layouts

241
00:10:41,130 --> 00:10:42,690
on the system.

242
00:10:42,690 --> 00:10:44,760
To run the locale control command,

243
00:10:44,760 --> 00:10:49,760
type in localectl space, the options space

244
00:10:51,240 --> 00:10:52,770
and the sub-command.

245
00:10:52,770 --> 00:10:54,660
Now, some of the options for this command

246
00:10:54,660 --> 00:10:57,420
include -H and the remote host.

247
00:10:57,420 --> 00:10:59,790
This option is going to execute the operation

248
00:10:59,790 --> 00:11:03,030
on a remote host that you specify using a hostname

249
00:11:03,030 --> 00:11:04,641
or IP address.

250
00:11:04,641 --> 00:11:07,230
-no-ask-password option

251
00:11:07,230 --> 00:11:09,030
is going to be used to prevent the user

252
00:11:09,030 --> 00:11:10,350
from being asked to authenticate

253
00:11:10,350 --> 00:11:12,900
when they try to perform a privileged task.

254
00:11:12,900 --> 00:11:15,690
The --no-pager option is going to be used

255
00:11:15,690 --> 00:11:17,520
to prevent the output from being piped

256
00:11:17,520 --> 00:11:19,530
into a paging utility.

257
00:11:19,530 --> 00:11:21,600
And the --no-convert option

258
00:11:21,600 --> 00:11:23,970
is going to be used to prevent a keymap change

259
00:11:23,970 --> 00:11:26,130
from the console, that's going to be applied to

260
00:11:26,130 --> 00:11:29,040
an X display server and vice versa.

261
00:11:29,040 --> 00:11:31,080
For example, if you're in the console,

262
00:11:31,080 --> 00:11:32,910
you only want to change the console.

263
00:11:32,910 --> 00:11:34,380
If you're in the graphical environment,

264
00:11:34,380 --> 00:11:36,990
you only want to change the graphical environment.

265
00:11:36,990 --> 00:11:38,310
Now the character encoding

266
00:11:38,310 --> 00:11:40,920
is the process of converting text into bytes.

267
00:11:40,920 --> 00:11:43,380
And decoding is the process of converting bytes

268
00:11:43,380 --> 00:11:44,850
back into text.

269
00:11:44,850 --> 00:11:47,130
Both of these concepts are really important,

270
00:11:47,130 --> 00:11:49,800
because text is much easier for us as humans

271
00:11:49,800 --> 00:11:52,200
to interact with, but computers

272
00:11:52,200 --> 00:11:54,870
like to process our data in bytes.

273
00:11:54,870 --> 00:11:57,240
In many systems, the default encoding

274
00:11:57,240 --> 00:12:00,210
is going to be set to UTF-8.

275
00:12:00,210 --> 00:12:02,700
And this is a Unicode character set.

276
00:12:02,700 --> 00:12:05,190
For example, the letter C

277
00:12:05,190 --> 00:12:09,960
is associated with the position number of U plus 0043

278
00:12:09,960 --> 00:12:13,620
inside the UTF-8 standard or Unicode.

279
00:12:13,620 --> 00:12:15,450
In Linux, the locale settings

280
00:12:15,450 --> 00:12:18,060
will determine what encoding scheme is going to be used

281
00:12:18,060 --> 00:12:19,230
by your system.

282
00:12:19,230 --> 00:12:20,640
The same general locale

283
00:12:20,640 --> 00:12:22,890
may have many different encoding options though,

284
00:12:22,890 --> 00:12:25,740
such as ASCII or UTF-8.

285
00:12:25,740 --> 00:12:28,740
Let's say, for example, you're looking in Germany

286
00:12:28,740 --> 00:12:32,100
de underscore DE.utf8

287
00:12:32,100 --> 00:12:37,100
and de underscore DE.iso88591

288
00:12:37,260 --> 00:12:40,920
are both set for German and the German language,

289
00:12:40,920 --> 00:12:42,300
but these sets

290
00:12:42,300 --> 00:12:44,610
are actually two different encoding standards.

291
00:12:44,610 --> 00:12:48,153
One is for UTF-8 and the other is for ASCII.

