Skip to content

Linux hostname configuration with hostnamectl

The hostnamectl command is the standard utility for managing the system hostname on Linux.^[600-developer-tools-vscode-vmware.md]

Setting the hostname

To permanently change the system hostname, use the set-hostname subcommand followed by the desired name.^[600-developer-tools-vscode-vmware.md]

hostnamectl set-hostname <new-hostname>

For example, to set the hostname to w20: ^[600-developer-tools-vscode-vmware.md]

hostnamectl set-hostname w20

You must log out and log back in (or reboot) for the change to reflect in your shell prompt.^[600-developer-tools-vscode-vmware.md]

Verifying network resolution

After changing the hostname, you may want to ensure the name resolves correctly across the network.^[600-developer-tools-vscode-vmware.md]

  1. Map IP to Hostname: Edit /etc/hosts to associate the new hostname with the local IP address.
  2. Ping: Use ping to verify connectivity.^[600-developer-tools-vscode-vmware.md]
  • [[Linux networking]]
  • [[Static IP configuration]]
  • [[DNS]]

Sources

^[600-developer-tools-vscode-vmware.md]