Solved: How to change hostname using nmtui or nmcli in redhat linux

In our last post we have seen how to change hostname manually or with hostnamectl .
In this post we will discuss how to change hostname with nmtui and nmcli tools.
nmtui
Let’s first try with nmtui tool
  • If you don’t have the nmtui tool installed, you can install it using yum
yum install NetworkManager-tui
  • Invoke the nmtui interface from the command line by executing as root user
nmtui
  • In the menu select “Set system hostname” .
  • Write the new hostname which you want to keep.  We want to change it to “prodvedas”.

  • To make it effective restart the “hostnamed” service
systemctl restart systemd-hostnamed
  • Now if you login with new session or do “su -” in same session you should see new hostname.
nmcli
Let’s try changing the hostname with nmcli tool in Redhat Linux.
  • To check the current hostname
nmcli general hostname
  • If you want to change the hostname
nmcli general hostname prodvedas
  • To make it effective restart hostnamed service
systemctl restart systemd-hostnamed
  • Now if you login with new session or do “su -” in same session you should see new hostname.
Hostname changed by any of the above method will be persistent across reboot.
If you are trying to change hostname of AWS EC2 linux instance the process will be slightly different. Refer this post to change AWS EC2 instance hostname.

No comments:

Post a Comment