How to change hostname in Debian 9

Share this post to your friends !
  • 1

SystemMen - This tutorial shows you how to change hostname in Debian 9. In essence, Debian 9 works just like Debian 8. So you can apply the article I wrote for Debian 8, like this article.

Change hostname in Debian 9

To display the current hostname information, run the following command.


Next, to see the hostname declared in the /etc/hosts file, run the command below. The information in this file is usually used for dns or services such as web servers.

cat /etc/hosts
how-to-change-hostname-in-debian-9-01 How to change hostname in Debian 9
Change the hostname in Debian 9 using ‘hostnamectl’ command.

To make a hostname change in Debian9, this is an OS using systemd. So we can use the hostnamectl command.

Use can read the article for Debian 8.

hostnamectl set-hostname systemmen

Next, run the following command to change the hostname in the hosts file, this is to ensure services such as dns or web server stable operation.

sed -i 's/debian9/systemmen/g' /etc/hosts

Check the new hostname

Now you exit the current ssh session.


Make the ssh connection again and check the new hostname as shown in the image above.

Actually, the new Linux operating system, using systemd, has made some tasks simpler. It also reduces the difference between operating systems or versions. This article you can apply to Debian 8, Debian 9, Ubuntu 16, CentOS or any Linux OS using systemd.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
  • 1
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.