On Debin 9+ user
sudo hostnamectl set-hostname host.example.com
And to check:
hostnamectl
On Debian 8 and older
, the hostname is set at startup thanks to the script /etc/init.d/hostname.sh which uses the file /etc/hostname. We can use this file to update the computer hostname and its FQDN (fully qualified domain name).
sudo hostnamectl set-hostname host.example.com
And to check:
hostnamectl
On Debian 8 and older
, the hostname is set at startup thanks to the script /etc/init.d/hostname.sh which uses the file /etc/hostname. We can use this file to update the computer hostname and its FQDN (fully qualified domain name).
Caution: in the /etc/hosts file, the hostname and FQDN order must be respected.
~$ echo "my-computer" > /etc/hostname
~$ echo "127.0.0.1 my-computer.my-domain.ext my-computer localhost" > /etc/hosts
~$ /etc/init.d/hostname.sh
~$ echo "127.0.0.1 my-computer.my-domain.ext my-computer localhost" > /etc/hosts
~$ /etc/init.d/hostname.sh
You can check the change with the following lines:
~$ hostname
my-computer
~$ hostname --fqdn
my-computer.my-domain.ext
my-computer
~$ hostname --fqdn
my-computer.my-domain.ext
No comments:
Post a Comment