Configure Hostname on Ubuntu Machine

Its easy to configure a hostname on an Ubuntu machine. You can use the command line tool hostnamectl. Lets see how its done:

  1. Open the terminal on your Ubuntu machine.
  2. Run one of the commands below to display the current hostname.
  3. $ hostname
    $ hostnamectl status
  4. Set the hostname using the command below , replacing “new_hostname” with the desired hostname.
  5. $ sudo hostnamectl set-hostname new_hostname
  6. Confirm the new hostname.
  7. $ hostname
  8. Additionally, you can also edit the file “/etc/hostname” and change the hostname to your desired one and reboot the machine to take effect.



Leave a reply

Your email address will not be published. Required fields are marked *


©2023 ZMATECH: Innovative solutions for your IT challenges.


We're not around right now. But you can send us an email and we'll get back to you, asap.


Log in with your credentials

Forgot your details?