Linux hostname management¶
Managing hostnames is a fundamental task in Linux system administration, particularly for configuring servers within a network or [[VMware]] environments. A hostname serves as the machine's identity, facilitating communication and management.
Viewing the hostname¶
To check the current hostname of the system, administrators use the hostnamectl command^[600-developer-linux-centos7-command.md].
Setting the hostname¶
The standard method for setting a new hostname involves the hostnamectl utility^[600-developer-linux-centos7-command.md]. The syntax requires root privileges and follows the format hostnamectl set-hostname <new_hostname>.^[600-developer-linux-centos7-command.md]
For the changes to fully take effect in the current session, users typically need to log out and log back in, or reboot the system^[600-developer__tools__vscode__vmware.md].
Configuring the hosts file¶
In addition to setting the system hostname, it is common practice to map hostnames to IP addresses locally. This is achieved by editing the /etc/hosts file^[600-developer-linux-centos7-command.md].
This configuration serves two main purposes:
1. It creates a local network map, allowing the system to recognize other nodes by name (e.g., mapping 192.168.79.10 to w10)^[600-developer__tools__vscode__vmware.md].
2. It ensures that the local system can resolve its own hostname correctly, which is critical for many network services.
Once the file is updated, network connectivity between defined hosts can be verified using commands like ping^[600-developer__tools__vscode__vmware.md].
Related Concepts¶
- [[Linux networking]]
- [[Static IP configuration]]
- [[SSH]]
- [[Systemd]]
Sources¶
600-developer-linux-centos7-command.md600-developer__tools__vscode__vmware.md