There’s quite a few parameters that hostnamectl command takes, all implementing additional flexibility in naming and tracking your nodes on infrastructure.
set-hostname – actually configuring the hostname (you don’t need to know config file locations, just enter the hostname)
set-chassis – easy way of confirming the hardware your OS is running on (and whether it’s a VM or not)
set-deployment – option to specify if your Linux box is development, staging or production
set-location – allows you to specify geographical location of the server (freeform text)
For example, here’s how I can specify that my Raspberry Pi is a server grade hardware:
root@becky:~#hostnamectl set-chassis "server"
… if we check now, we will see the Chassis field showing:
root@becky:~#hostnamectl
Static hostname: becky
Icon name: computer-server
Chassis: server
Machine ID: 18634e1404184594bc66ddacfba0bf43
Boot ID: 7f9b03a40fdf492bb0c0dd3b6f6a7e94
Operating System: Raspbian GNU/Linux 9 (stretch)
Kernel: Linux 4.14.48-v7+
Architecture: arm
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!