Changing Linux system hostname hostname is the name of your next machine that is assigned during the
first install and oftentime a machine is repurposed or decommissioned or used for something else, then
you have to change its hostname to change the hostname.
The command that is used is hostname, seatbelt, dash set, dash, hostname space, new hostname.
This is the command.
I believe there is no dash in the middle, but I'll try it out.
Hostname said dash hostname.
And of course the new hostname.
The files that are used to save the new hostname in Linux seven OS version.
It's Etsi Hostname, the older version of Linux, which was version six.
The configuration file for hostname was ETSI six config and network.
So again, let's try our changing our hostname of our Linux machine in our lab environment on Linux
machine.
And right now when you type hostname, this is the name of our machine, my first Linux OS.
Now I want to change this hostname to a different hostname because my company came up with a new standard.
Now every machine has to comply with the new standard requirement.
So that's why I want to change it.
So in order to change a hostname, you have to first become root.
Cause root is only the one who has the power to do that.
OK, well organized.
All right.
And now I'm going to run the command hostname before I run this command.
I just wanted to tell you the file that keeps your host name information is ETSI.
Post name is Chrissy, and I had this father has my hostname, I could go into this file directly and
modify this hostname and then reboot the system at work or I could just simply run hostname CTL command,
set hostname and the new host name.
So outputted the new host name.
New York City host one, let's say, because my machine is located in New York City and it's a number
one host, so I'm just, you know, making it up to comply with the standard my company came up with.
All right, perfect.
So once I have it, I run the command.
It ran.
So now when you do cat atse hostname, you should see the new hostname there.
Yes.
You see that New York City host one, but when you type hostname, it gives you the host name of your
new machine.
But if you notice here, you'll prompt my first Linux OS has your prompt has the old hostname.
Why is that?
Because this shell that I'm logged into, this shell has to be restarted or the whole system has to
reboot in order to read the new hostname that we created.
So the only way to do that is simple reboot.
I'll just run reboot or another command for reboot as in at six.
So this time I'll run in at six and we'll wait for the system to come back online.
Give it a couple of minutes.
Log in from a log in.
Some time the virtual machine will take a little longer to come back online, depending on your laptop
speed.
So I'm going to go and right click open terminal.
And you'll see now it has the new host name.
NYC host one so this is how you change the host name.
Do you guys know how to change the host name and windows?
Well, I think you might.
If not, then you should look into it, because as administrator, you will have to work a little bit
of in the Windows environment to you.
Just go into your my computer.
Right.
Click on properties and change the host name.
So it is simple.
And windows through the GUI and Linux is just running one command.
It's simple here as well.
So I'm going to change it back to my original hostname by becoming root.
So this will stay consistent and this time I'll just modify the C hostname file.
My first Lennix OS, right, this is my original hostname.
And when you were on hostname this time, it will still give you that because the the the process that
does the hostname changes.
That process hasn't been restarted.
The only way to do it is to restart, like hostname the command that we run before.
But anyway, I'm just going to simply go ahead and restart a reboot my computer again.
So the changes will take place and put my system back to my original hostname.