How to Change Hostname on Debian 9 Linux

A quick tutorial for the steps required to change the hostname on your Debian 9 system.

The hostname is set at the time when the Debian operating system is installed or if you are spinning up a virtual machine it is dynamically assigned to the instance at startup.

The method described in this tutorial will work without the need of restarting your Linux system.

Prerequisites:

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

Display the Current Hostname:

Copy to Clipboard1

hostnamectl

Change the Hostname:

Step 1. Change the hostname

Copy to Clipboard1

sudo hostnamectl set-hostname new-host-name.example.com

Step 2. Edit the hosts file:

Copy to Clipboard1

sudo nano /etc/hosts

The file should look similar to this one:Copy to Clipboard1

127.0.0.1 localhost
127.0.0.1 new-host-name.example.com 
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Share:

More Posts

March 2022 – Kids on the Yard PR

“I can relate to this! Parents having a very tough time keeping their kids educational on track…” Sarah Maruani, a first-grade teacher, has founded Kids

Happy smiling arab schoolgirl using phone for virtual online study at home.

Online Summer Camp 2022

Numerous schools are supplying online guideline to struggling visitors. Unfortunately, there is an absence of research study on the effect of online small-group analysis intervention,

Sign up for our newsletters

SEO

Book Now Free SEO Consultation

Commerce

Take your ecommerce site to next the level

Development

Website Development