How to change hostname in Debian 9

by Daniel Pham
Published: Updated:

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.

hostname

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
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.

exit

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.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.