Skip to content

Instantly share code, notes, and snippets.

@liyang85
Created September 13, 2017 06:47
Show Gist options
  • Save liyang85/7960e285241d377c08f9d7d573641e68 to your computer and use it in GitHub Desktop.
Save liyang85/7960e285241d377c08f9d7d573641e68 to your computer and use it in GitHub Desktop.
Change hostname on CentOS
# Part 1: CentOS 6
vim /etc/sysconfig/network
HOSTNAME=my_hostname
source /etc/sysconfig/network
# `hostname` can set the host name until reboot,
# it also can show the host name
hostname
# Part 2: CentOS 7
hostnamectl set-hostname my_hostname
hostnamectl status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment