Host Name Configuration (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
>> Hello Cybrarians and welcome back to
00:00
the Linux Plus course here at Cybrary.
00:00
In today's lesson, we're going to be
00:00
discussing host name configuration.
00:00
Upon completion of today's lesson,
00:00
you'll be able to determine where
00:00
the host name is stored in Linux,
00:00
both in CentOS and Ubuntu,
00:00
and we're going to use commands to
00:00
modify that system host name.
00:00
Let's go ahead and get started with some demo time.
00:00
In today's lesson,
00:00
and in today's demo,
00:00
we're going to get started in Ubuntu.
00:00
In Ubuntu, the host name is
00:00
actually just stored in etc host,
00:00
and we can use our concatenate, cat command,
00:00
to just print the output of
00:00
etc host right here to our screen.
00:00
Let's call standard out. What we're going to
00:00
see in here is that the line
00:00
is Ubuntu 20 right here with the IP address 127.0.1.1.
00:00
For those of us who are coming
00:00
from the Network Plus Course,
00:00
127.0.0.1, may look familiar.
00:00
That's the local host address,
00:00
it's loopback address,
00:00
but 127.0.1.1 is a little weird.
00:00
That's a quirk from Ubuntu systems.
00:00
What it is, is it's an actual IP address
00:00
that is associated
00:00
just locally with the system for a system
00:00
that doesn't have a static IP address.
00:00
It's getting a dynamic IP address
00:00
on this virtual machine from DHCP,
00:00
which we'll also talk about later.
00:00
That's why you see
00:00
that extra line entry here in etc host.
00:00
Just for our purposes,
00:00
just know that etc host is where
00:00
>> you find the host name,
00:00
>> and the host name for this system is Ubuntu 20.
00:00
I also have an entry in here for CentOS system.
00:00
That's just a nice workaround
00:00
so that I don't have to remember
00:00
the IP address when I bounce
00:00
back and forth between the machines later.
00:00
If you wanted to change the host name on this system,
00:00
you can do so in a couple of ways.
00:00
The first way you can do that is
00:00
by elevating your privileges and
00:00
then running the command host name and
00:00
passing in a new host name for the system.
00:00
For our sake, let's change this from
00:00
Ubuntu 20 to just Ubuntu and hit Enter.
00:00
Now, if we instantiate a new shell
00:00
>> just by running bash,
00:00
>> we'll see that the host name was changed from
00:00
Ubuntu 20 to just Ubuntu,
00:00
but not so fast.
00:00
This is just a temporary change.
00:00
If we were to cat etc host,
00:00
we see that the host name in here is still Ubuntu 20.
00:00
If we wanted to have that be persistent,
00:00
we would need to modify
00:00
etc host in order to change this host name.
00:00
That's pretty much what you need to know
00:00
for host names in Ubuntu.
00:00
Let's move over to our CentOS system.
00:00
We're looking at our CentOS system here.
00:00
When you're talking about CentOS,
00:00
you have to understand the host name is
00:00
nowadays stored in etc host name file.
00:00
Just like we did with Ubuntu,
00:00
we can go ahead and concatenate that file,
00:00
cat it out to print it out here to the screen.
00:00
We can see that our host name is centos,
00:00
and that matches the host name that we see
00:00
here in our shell prompt, centos8.
00:00
If we wanted to change it,
00:00
we could do it the same way we did in Ubuntu.
00:00
We can temporarily change it
00:00
>> using the host name command.
00:00
>> We can modify the host name
00:00
from centos8 to let's say centos.
00:00
I need to provide
00:00
my password so I can elevate my privileges
00:00
and now I can do a new bash shell.
00:00
We see that the host name has changed to centos.
00:00
Just like we saw before,
00:00
this isn't a persistent change.
00:00
If I go back in here,
00:00
I'm going to see that the host name
00:00
is set to centos temporarily,
00:00
but if I hit etc host,
00:00
print it out yet as the host name rather,
00:00
what I'm going to find is still centos8.
00:00
Let's maximize the window here again.
00:00
If we wanted to change
00:00
this to match this, in other words,
00:00
we wanted the host name to be
00:00
set persistently to centos instead of centos8,
00:00
we can use another really nice command that was
00:00
released with RHEL 7,
00:00
Red Hat Enterprise Linux 7,
00:00
and that command is called hostnamectl.
00:00
Just like we saw with host name,
00:00
we need to run this with elevated privileges.
00:00
I'll run pseudo hostnamectl,
00:00
and then we can use the command set host name,
00:00
and we can type in the new host
00:00
name we want to give the system,
00:00
so we can change it from centos8 and to just centos.
00:00
Hit Enter and type in the password again.
00:00
If I cat etc host name,
00:00
we see that the host name has
00:00
permanently changed to centos.
00:00
If we reboot the system,
00:00
it will remain with this host name.
00:00
Keep in mind that this is the case
00:00
for newer RPM-based distributions.
00:00
The host name lives in etc host name.
00:00
In Ubuntu distributions the host name
00:00
>> lives in etc host.
00:00
>> You may see questions on
00:00
the exam about etc sysconfig network,
00:00
and that's where host names were stored in
00:00
older RPM-based distributions of Linux,
00:00
but that's no longer the case today.
00:00
We come to the end of this lesson.
00:00
In today's lesson, we covered the locations that
00:00
store the host name in both Ubuntu and CentOS,
00:00
and the commands that you can use to
00:00
configure the host name.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next