hostname -f
hostnamectl
ilyasa@webserver:~$ hostname
webserver
ilyasa@webserver:~$ hostname -f
webserver.yas.lab
ilyasa@webserver:~$ hostnamectl
Static hostname: webserver
Icon name: computer-container
Chassis: container ☐
Machine ID: f91ff07142654e1d9eacfbb77447a3db
Boot ID: bfc005a4abad4e7692cd044ec61a0e1b
Virtualization: lxc
Operating System: Ubuntu 24.04 LTS
Kernel: Linux 6.8.12-1-pve
Architecture: x86-64
ilyasa@webserver:~$
- Using systemd API, hostnamectl
sudo hostnamectl set-hostname new-hostname
sudo nano /etc/hostname
sudo nano /etc/hosts
cat /etc/hostname
ilyasa@ubuntu-desktop:~$ cat /etc/hostname
ubuntu-desktop
cat /etc/hosts
ilyasa@ubuntu-desktop:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu-desktop.yas.lab ubuntu-desktop
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters