Linux

How to Change Hostname in Ubuntu in 2021

Here is a simple command you can use to change the hostname in Ubuntu.

how to

sudo hostnamectl set-hostname new_hostname

Read below to find out what is hostname and another way to change it in Ubuntu-server

What is the hostname in Ubuntu?

By definition, hostname is a name that is assigned to a “host” here host means a computer on a network. So it basically means the name of your computer. This hostname is used for identification of your computer on the network

By default, it is set up when you install Ubuntu or any Linux on your system. The name that you type at the time of installation is used with hardware model number as a hostname. To know what’s the hostname of your system type below command in terminal.

hostnamectl

Now you can see whats current hostname of your system in terminal in static hostname section.

Why change hostname?

See when you were installing Ubuntu you thought naming Tom will be great, but now you are thinking NO Jerry is better. There can be various reasons due to which you might want to change your system’s hostname. But just don’t use the same name for two computers on the same network as it might create problems. Although whatever the reason to change hostname here is a simple method to do so.

How to change in Ubuntu-Linux

It’s quite easy to change the hostname in Ubuntu Linux. Just open Terminal either by searching or by pressing Ctrl + Alt + T keys together. Type below commands and you are done.

hostnamectl set-hostname new_hostname

Here replace new_hostname with whatever you would like to keep. You can verify by entering hostnamectl command in terminal.

But this method doesn’t seem to work on Ubuntu-Server so if you are using Ubuntu-server follow the method below.

How to change in Ubuntu-Server

Type the following commands in terminal:

sudo hostname new_server_name

Next, edit the /ect/hostname file and update hostname:

sudo nano /etc/hostname

Finally, edit the /etc/hosts file and update the lines that read your old-host-name:

sudo nano /etc/hosts

From: 127.0.1.1 Old_hostname to 127.0.1.1 new_hostname

Save and close the file and its done.

If you are facing any problems please do let us know in comments. Any other problem you are facing on your computer and want to fix it do let us know in comments we would try to help you as much as we can.

Do you want to know how to screenshot on Snapchat without them knowing? here is how you can do it.

Akash

Recent Posts

Linux Software must have to improve Productivity

You can utilize a wide range of tools as a Linux user to keep organized, manage your time, and become… Read More

2 years ago

How to get Complete details of an Audio Video File

Have you ever caught yourself in a situation where you need details of an audio/ video media file? When you… Read More

3 years ago

Fix Windows 10 showing wrong time in dual boot with Linux

If you have installed Linux alongside windows in the dual boot you might have noticed that every time you boot… Read More

3 years ago

How to update Linux Kernel to the latest version easily

Linux kernel is like the core of the operating system. It's a piece of software that works as a middle… Read More

4 years ago

3 Methods for How to Install Python on Linux System

Nowadays, most Linux Distros already have Python preinstalled. But you might have a distribution that might not have Python preinstalled.… Read More

4 years ago

How to Install Python on Windows 10 to begin coding

Python is one of the most popular and easy to learn programming languages. Its a widely used high-level programming language… Read More

4 years ago

Just so that you know we use cookies on our website. Want to know more

read here