How to Change Computer Name in Ubuntu
Quick step by step guide on using hostnamectl to change your computer name in Ubuntu. This works for servers and ubuntu desktop.
Check the current name
Open a new terminal and type the following command to see the current computer name or 'hostname'.
hostnamectlThis will return a message which looks something like this:
 Static hostname: myhostname
       Icon name: computer-laptop
         Chassis: laptop 💻
      Machine ID: xxx
         Boot ID: xxx
Operating System: Ubuntu 23.10                    
          Kernel: Linux 6.5.0-14-generic
    Architecture: x86-64
 Hardware Vendor: Dell
  Hardware Model: Inspiron 15
Firmware Version: xxx
   Firmware Date: Mon 2022-09-12Change the name
To change the computer name, or hostname we can enter the following command into the terminal:
hostnamectl set-hostname mynewhostnameIf you type hostnamectl again you should see that the new name is displayed next to Static hostname.
 Static hostname: mynewhostname
       Icon name: computer-laptop
         Chassis: laptop 💻
      Machine ID: xxx
         Boot ID: xxx
Operating System: Ubuntu 23.10                    
          Kernel: Linux 6.5.0-14-generic
    Architecture: x86-64
 Hardware Vendor: Dell
  Hardware Model: Inspiron 15
Firmware Version: xxx
   Firmware Date: Mon 2022-09-12
 
             
                                 
            