Skip to content

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  localhost  {NEW host name}

2 revise /etc/sysconfig/network

HOSTNAME={NEW host name}

Using hostnamectl

hostnamectl set-hostname NAME

  1. License under CC BY-NC 4.0
  2. Copyright issue feedback, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try iOS App