:bulb: This guide describes how to change the hostname on Ubuntu.

[01] Check the Current Hostname

1
2
3
4
5
hostname

# ex
root@gmaster:~# hostname
gmaster

[02] Change the Hostname

1
2
3
4
5
6
hostnamectl set-hostname ${hostname}

# ex
root@gmaster:~# hostnamectl set-hostname gworker01
root@gmaster:~# hostname
gworker01

After that, the change takes effect once you close and reopen the terminal, or reboot the system.

:small_blue_diamond:Reference: How to do it without rebooting (askubuntu)