Localization Commands (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey there Cybrarians.
00:00
Welcome back to the Linux plus course here at Cybrary.
00:00
I'm your instructor, Rob Goelz.
00:00
In today's lesson, we're going to
00:00
be discussing localization commands.
00:00
Upon completing this lesson,
00:00
you're going to understand how to use
00:00
localization commands such as locale,
00:00
localectl, timedatectl,
00:00
date, and the hardware clock command, hwclock.
00:00
We used the locale command back in Lesson 6.2
00:00
>> where we at least saw the output of it on the screen.
00:00
>> It displays all the locale categories,
00:00
all the environmental variables
00:00
that are related to localization.
00:00
The localectl command just controls and modifies
00:00
those system locale settings
00:00
that locale command displays.
00:00
There are a bunch of different time commands
00:00
we're going to talk about here,
00:00
but a few of them are timedatectl,
00:00
which is used to set time and the time zone,
00:00
we can use the date command to set or print the time,
00:00
and the hwclock is used to
00:00
manage the hardware clock on a physical system.
00:00
Let's see all of this in
00:00
action though with some demo time.
00:00
Here we are over Ubuntu environment,
00:00
and the first thing we'll do is we'll
00:00
run the locale command.
00:00
Here we can see that output that we saw back in 6.2.
00:00
These are all the environmental variables for
00:00
localization that are set up on this system.
00:00
We can also run localectl.
00:00
What this will do is it'll just
00:00
>> display a small subset of
00:00
>> the information from the locale command
00:00
>> like this system locale,
00:00
>> key map, and so on, and so forth.
00:00
The nice part about localectl though is, as I said,
00:00
we can also use it to set
00:00
different environment variables,
00:00
different localization settings,
00:00
>> so we use localectl set-locale to change something.
00:00
>> In fact, let's go ahead and become sudo.
00:00
Let's elevate our privileges so that we don't get
00:00
any trouble and we try to run this.
00:00
What I'm going to do is I'm going to change this
00:00
from US English to Canadian English,
00:00
>> and we'll play around with that.
00:00
>> Let's go ahead and type in.
00:00
We're going to make this Unicode Format
00:00
8 and hit "Enter".
00:00
Apologies that's set-locale,
00:00
not set local. There we are.
00:00
Now if we run the locale command again,
00:00
we'll see that the language has changed.
00:00
Now if we run the localectl command again,
00:00
we'll see that the system locale has changed to
00:00
use en_CA.UTF-8, UTF one byte.
00:00
Let's move over to our CentOS system.
00:00
Here we are over our CentOS system,
00:00
and recall that we couldn't see EC local time,
00:00
and we couldn't cut it out,
00:00
it's a binary file.
00:00
However, we can run a command called
00:00
timedatectl over here and
00:00
this will display all sorts of time information.
00:00
So we'll see the time zone
00:00
and we'll see our local time on
00:00
our system in 24 hour time and universal time,
00:00
RTC time, all of these good things.
00:00
We can also set the time zone with timedatectl.
00:00
Again, I'm going to use sudo to elevate
00:00
my privileges here and then I'm going to run
00:00
this command timedatectl,
00:00
and I'm going to set-timezone.
00:00
I'm going to change it so that we're no
00:00
longer in the East Coast here,
00:00
we're going to be over on the West Coast.
00:00
We're going to change this time zone to
00:00
America/Los_Angeles.
00:00
Let's go ahead and hit "Enter",
00:00
>> and type in the password
00:00
>> for my user to elevate my privileges.
00:00
>> Now if we run timedatectl,
00:00
we can see that the time has changed
00:00
>> from America/New_York to America/Los_Angeles.
00:00
>> Another thing that we could do is
00:00
use the date command to look at time on our system.
00:00
We can just hit "Date" and it'll output
00:00
the date in 24-hour format here.
00:00
That tells us that we're over on the West Coast.
00:00
It is 8:52,
00:00
while it's actually 11:52 here
00:00
>> locally on the East Coast.
00:00
>> We can also, if we wanted to set
00:00
the time with the date command,
00:00
and you can do that with date -s,
00:00
and then you can actually specify,
00:00
let's say we wanted to set this back couple of minutes,
00:00
we can do copy this and change this from 52 to 50
00:00
and we can say that that is
00:00
PDT 2021.
00:00
We're going to put that all in quotes so that it
00:00
doesn't try and use those spaces.
00:00
We're now trying to escape them
00:00
>> with brief back quotes.
00:00
>> Let's become sudo.
00:00
Let's elevate our privileges to
00:00
do that as well, and there we go.
00:00
Now I see the time has been set back a couple
00:00
of minutes there from what it was before.
00:00
Another thing we're going to want to
00:00
look at as well as we discussed,
00:00
the hardware clock, the hwclock command,
00:00
and by itself, we can just run hwclock,
00:00
and what this is going to do is it's going to
00:00
display the real time clock.
00:00
Or it would but here's the thing.
00:00
This is a virtual machine.
00:00
There is no hardware clock,
00:00
there is no physical environment.
00:00
Let me just talk a little bit about this.
00:00
The hwclock -s option is used to
00:00
set the system time using the hardware clock.
00:00
However, you can also use
00:00
the hwclock -w command to
00:00
set the hardware from the system itself.
00:00
You could use s to keep the system
00:00
in sync with the hardware clock
00:00
>> and use w to keep the hardware
00:00
>> in sync with the system clock.
00:00
>> With that, we've reached the end of the lesson.
00:00
In today's lesson, we covered
00:00
localization commands you may
00:00
encounter on the Linux plus exam,
00:00
including locale, localectl,
00:00
timedatectl, date, and hwclock.
00:00
Thank you so much for being here,
00:00
>> and I look forward to seeing you in our next lesson.
Up Next