Debian 9 change hostname permanently

Debian 9 change hostname is done very similarly to the previous Debian versions. With one major difference. It is how you apply the changes. If you don’t apply the changes, the changes will not be taken into effect until you reboot or restart your system. The same way if you use the hostname commands to change the hostname, the hostname is reverted when you reboot. Let us see how to Debian 9 change hostname permanently.

In the following example, let us assume the server name is

Debian 9 change hostname permanently

If you run the command hostname, it will return example. That is the hostname of your system.

root@example:~# hostname

Domain Name

When adding the parameter -d to the hostname command it will give you the domain name currently set for your system.

root@example:~# hostname -d

FQDN / Fully Qualified Domain Name

Change the parameter to -f and you get the FQDN or Fully Qualified Domain Name instead. Here is an example.

root@example:~# hostname -f

Change the hostname

To change the hostname you need to edit the /etc/hostname file. If you use the hostname command, it will not be permanent. The hostname file will only contain the hostname. The picture below is from one of my database servers.

Debian 9 change hostname 2

Change the Domain or FQDN

Any changes to the domain name or the FQDN has to be done in the /etc/hosts file. Here is an example of how a hosts file looks. Again from my database server.

Debian 9 change hostname 3

Apply the changes

As mentioned above the changes needs to be applied, like restarting or reloading the hostname service. If not the changes will not be applied until you reboot or restart your system.

This is how you apply the settings on a Debian 9 system:

sudo hostname -F /etc/hostname

If you are looking for how to change hostname, domain or fqdn on Debian 8 or earlier, check out Debian – Change hostname, domain or FQDN permanently. Or looking for how to change the hostname on an Ubuntu system permanent.

Check out the video below to see how it works.

That is how Debian 9 change hostname works.

About Author

Related Posts

php8 gd

PHP8 gd Activate after installation

PHP8 GD activate after installation. GD doesn’t get activated by default. Not even a reboot after installation will activate it. So how do we do it? In…

Debian 12: linux-image-6.1.0-10amd64

Troubleshooting dependency issues in Debian 12: Resolving linux-image-6.1.0-10amd64 package dependency problems. If you installed the Debian 12 from the live image the issue is the raspi-firmware. Even…

4 Best Free Nas Software That Is Open Source

Free NAS software or operating systems that are free to use and will turn a computer into a NAS more advanced than the dedicated boxes sold. What…

Raspbian default password

Raspbian default password

Looking for the Raspbian default password? It is the most essential username and password that you will need for your raspberry. At least if you are running…

OpenMediaVault default password

OpenMediaVault default password

OpenMediaVault default password is printed in the documentation. I did not see it the first time I installed it either. So I had to do some detective…

Debian change dns

Debian change DNS settings to a new DNS

Debian change DNS settings for speed improvement or privacy. It is really easy to do. So let us see how it’s done and get to it. The…

Leave a Reply