It is important to set a correct hostname on your VPS. The hostname is used by many applications to identify themselves on a network / the internet. Therefore, an incorrectly configured hostname can cause unexpected problems.
In this tutorial we show how you can check and/or change your current hostname in Debian 11.
Checking the hostname
The current hostname can be retrieved with the command:
hostname
Or for more extensive information use the command:
hostnamectl
Changing the hostname
There are two recommended methods to customize or view your hostname:
- thehostnamectl-command
- thehostname-command
Only the changes of the first option remain intact after a restart. You change your hostname with these options as follows:
-
Hostnamectl:
Use the command below and replace server.yourdomain.com with your desired hostname:hostnamectl set-hostname server.yourdomain.com
-
hostname:
Use the command below and replace server.yourdomain.com with your desired hostname:hostname server.yourdomain.com