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]
- Map IP to Hostname: Edit
/etc/hoststo associate the new hostname with the local IP address. - Ping: Use
pingto verify connectivity.^[600-developer-tools-vscode-vmware.md]
Related Concepts¶
- [[Linux networking]]
- [[Static IP configuration]]
- [[DNS]]
Sources¶
^[600-developer-tools-vscode-vmware.md]