We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Change hostname on Linux Using nmcli

Learn how to – How To Change hostname on Linux Using nmcli.

How can I set machine hostname on a Linux machine using NMCLI?. Is it possible to change hostname on CentOS/RHEL/Fedora/Ubuntu/Debian/RHCOS/FCOS machine using nmcli Network management tool?. The answer to both questions is YES!. You can change or set hostname of a Linux system running Network Manager using nmcli. Here is how to..

Check if the hostname is already configured with other tools such as hostnamectl or manually editing hostname files.

$ hostnamectl
   Static hostname: n/a
Transient hostname: node01.ocp.example.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 3f47d43533514bb6bcc03d51b7468459
           Boot ID: c4d5933c9cdc45bf8a77a8024e3c19f3
    Virtualization: vmware
  Operating System: Red Hat Enterprise Linux CoreOS 43.81.202002170853.0 (Ootpa)
            Kernel: Linux 4.18.0-147.5.1.el8_1.x86_64
      Architecture: x86-64

I noted on Red Hat CoreOS that when you set hostname with hostnamectl, it disappears upon reboot. But when you use nmcli, the hostname persists across system reboots. So this is how you can set hostname using nmcli.

sudo nmcli general hostname <hostname>

In my example, I’ll run:

sudo nmcli general hostname node01.ocp.example.com

Confirm that the hostname has been set correctly:

$ nmcli general hostname 
node01.ocp.example.com

There you have it.. You have successfully set or changed hostname on a Linux machine with ncmli command line tool.

More on Linux:

Cart

Your Cart is Empty

Back To Shop