How to change hostname in Debian 9


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.

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

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.

«« »»