View and modify the machine name in Linux
We often need to copy virtual machines in VMWare. For new machines to be copied, we need to modify the machine name. Otherwise, there will be conflicts in the same LAN, the following describes how to view and modify the machine name in Linux:
1. view the machine name of the system:
Log on as the root user and enter hostname in the terminal console.
[Root @ bkjia] # hostname
Bkjia
2. Temporarily modify the machine Name:
[Root @ bkjia] # hostname yourname
[Root @ bkjia] # hostname
Yourname
Note: However, the modification in step 1 can only be temporarily valid, and the machine is restarted and restored. To make the modification take effect permanently, continue with the following steps:
3. Modify the hosts file (Path:/etc/hosts ):
[Root @ bkjia] # vi/etc/hosts
Change all original hosts names to the ones you want to change. In addition, note that the ip address in the hosts file must be changed to the current ip address of the system (ip address query method: # ifconfig)
4. Modify the network file (Path:/etc/sysconfig/network ):
[Root @ bkjia] # vi/etc/sysconfig/network
Replace XXX in hostname = XXX with the name you want to change.
5. Restart the machine:
[Root @ bkjia] # reboot
OK. The modification is complete ~~~~~~~~
This article permanently updates the link address: