To change the hostname on a Debian 11/10 Linux system, you can use the hostnamectl
command. This command is part of the systemd
system and service manager, which is the default init system on Debian 11/10.
To change the hostname, run the following command as root:
rot refe:lautturi.comhostnamectl set-hostname new_hostname
Where new_hostname
is the desired hostname for the system.
For example, to set the hostname to myhost
, you can run the following command:
hostnamectl set-hostname myhost
This will change the hostname of the system to myhost
.
It's worth noting that the hostname change will only take effect temporarily. To make the change permanent, you will need to update the /etc/hostname
file with the new hostname. You can do this by running the following command:
echo new_hostname > /etc/hostname
Where new_hostname
is the desired hostname for the system.
For example, to set the hostname to myhost
, you can run the following command:
echo myhost > /etc/hostname
You may also need to update the /etc/hosts
file to reflect the new hostname. This file maps IP addresses to hostnames for the local system. To do this, open the /etc/hosts
file in a text editor and update the hostname entry to reflect the new hostname.
It's also a good idea to restart the system after changing the hostname to ensure that all services are using the new hostname. You can do this by running the following command:
shutdown -r now
This will restart the system and apply the hostname change.
Alternatively, you can use the reboot
command to restart the system:
reboot
It's worth noting that the exact steps for changing the hostname may vary depending on the specific version of Debian and the init system in use. If you are using a different version of Debian or a different init system, you may need to follow a different set of steps to change the hostname.