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.


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

Display the Current Hostname:

Copy to Clipboard1


Change the Hostname:

Step 1. Change the hostname

Copy to Clipboard1

sudo hostnamectl set-hostname

Step 2. Edit the hosts file:

Copy to Clipboard1

sudo nano /etc/hosts

The file should look similar to this one:Copy to Clipboard1 localhost 
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


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


Book Now Free SEO Consultation


Take your ecommerce site to next the level


Website Development