How to change hostname in Ubuntu 16

Share this post to your friends !
  • 1
    Share

How to change hostname in Ubuntu 16
5 (100%) 1 vote[s]

SystemMen - How to change the hostname in Ubuntu 16. This article will guide you how to change hostname in Ubuntu server 16. This article can be used for operating systems that are using systemd. Currently, Ubuntu version 16 or later, CentOS version 7 or later, these are the two most popular OS are using systemd.

Check the current hostname

You run the following command to check the current hostname:

hostname
cat /etc/hostname
how-to-change-hostname-in-ubuntu-16-01 How to change hostname in Ubuntu 16
Command to check the current hostname in Ubuntu 16.

Change hostname in Ubuntu 16

For operating systems that use systemd (Ubuntu 16 or later, CentOS 7 or later), there is support for a command that lets you change hostnames quickly.

hostnamectl
how-to-change-hostname-in-ubuntu-16-02 How to change hostname in Ubuntu 16
Command ‘hostnamectl’ to display the current hostname information.

To change the hostname using the hostnamectl command, type the following command:

hostnamectl set-hostname your-new-hostname

For example, i will set the new hostname is writebash:

hostnamectl set-hostname writebash

After you run the command, you must exit the current ssh session or logout in the console window. You can then login and check the new hostname.

exit

Change hostname in older Ubuntu

For older Ubuntu OSs, do not use systemd. You must change the hostname in the following two files:

nano /etc/hostname

In the /etc/hostname file, there is only one line. You delete the old hostname in the file and replace the new hostname.

nano /etc/hosts
how-to-change-hostname-in-ubuntu-16-03 How to change hostname in Ubuntu 16
Change hostname in /etc/hosts file.

After changing the hostname in the two files above, you reboot the system.

reboot

Conclusion

This article is about how to change the hostname in the Ubuntu operating system in general and the operating system Ubuntu server 16 in particular. To note with the Ubuntu operating system older than 16, you should change and reboot the system without installing anything.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.


Share this post to your friends !
  • 1
    Share
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.