Change hostname for Linux
Here are some methods to change hostname for a certain Linux system.
One-time Change
Side effect, ineffective after reboot
hostname {NEW host name}
Permanently Change
1 revise /etc/hosts
127.0.0.1 localhost {NEW host name}
2 revise /etc/sysconfig/network
HOSTNAME={NEW host name}
Using hostnamectl
hostnamectl set-hostname NAME
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here