Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

Ubuntu 18.04 LTS change hostname permanently

by Editorial Staff
November 7, 2018
in Linux
Reading Time: 3 mins read

[ad_1]

I am a new Ubuntu Linux 18.04 LTS cloud server user. By default my serer name to ‘localhost’ during installation but now I would like to change the computer name to ‘u1804-nixcraft’. Can you tell me how do I remove localhost and set it to u1804-nixcraft on Ubuntu 18.04 Linux? How do I change the Ubuntu computer name from ‘localhost’ to ‘u1804-nixcraft’? Can you tell me more about Ubuntu Linux change hostname command?

You need to use the hostnamectl command to see or set the Ubuntu 18.04 LTS system’s host name. The host name or computer name is usually at system startup in /etc/hostname file. Open the terminal application and type the following commands to set or change hostname or computer name on Ubuntu.

How to display the current Ubuntu hostname

Simply type the following command:
$ hostnamectl
Ubuntu 18.04 LTS see current hostname command

Ubuntu 18.04 LTS change hostname permanently

The procedure to change the computer name on Ubuntu 18.04 LTS:

  1. Type the hostnamectl command :
    sudo hostnamectl set-hostname newNameHere
    Delete the old name and setup new name.
  2. Next Edit the /etc/hosts file:
    sudo nano /etc/hosts
    Replace any occurrence of the existing computer name with your new one.
  3. Reboot the system to changes take effect:
    sudo reboot

How to change hostname on Ubuntu 18.04 without a system restart

Let us see current setting just type the following command:
$ hostnamectl
Next change hostname from localhost to u1804-nixcraft, enter:
$ hostnamectl set-hostname u1804-nixcraft
Verify new changes:
$ hostnamectl
Ubuntu 18.04 LTS change hostname permanently
Find your public or private IP address by running the ip command:
$ ip a
$ ip a s eth0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 40:9f:38:28:f6:b5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.24/24 brd 192.168.2.255 scope global noprefixroute enp6s0
       valid_lft forever preferred_lft forever
    inet6 fe80::429f:38ff:fe28:f6b5/64 scope link 
       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 40:9f:38:28:f6:b5 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.24/24 brd 192.168.2.255 scope global noprefixroute enp6s0
valid_lft forever preferred_lft forever
inet6 fe80::429f:38ff:fe28:f6b5/64 scope link
valid_lft forever preferred_lft forever

See also  How to install LAMP on Debian 10 Buster Server/Desktop

Update /etc/hosts file with that IP address such as 192.168.2.24 using a text editor such as vim command/nano command:
$ sudo vi /etc/hosts
OR
$ sudo nano /etc/hosts
Update/append:
192.168.2.24 u1804-nixcraft
Make sure you replace any occurrence of the old computer name with your new one too. Save and close the file in vim.

Conclusion

You learned how to change hostname permanently when using Ubuntu 18.04 LTS as per your needs.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

[ad_2]

Related Posts

Top Commands to Check the Running Processes in Linux
Linux

Top Commands to Check the Running Processes in Linux

May 27, 2022
4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error
Linux

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022
How Common Signals are Used in Kubernetes Pod Management
Linux

How Common Signals are Used in Kubernetes Pod Management

November 20, 2021

Leave a Reply Cancel reply

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

Top 26 Best NYAA Alternatives To Watch Anime Free

Top 26 Best NYAA Alternatives To Watch Anime Free

July 4, 2022
30 VUDU Alternatives To Watch Movies And TV Shows Online

30 VUDU Alternatives To Watch Movies And TV Shows Online

July 3, 2022
finland web hosting reviews

Top 10 Finland Web Hosting Reviews 2022

July 3, 2022
warehouse management systems software

Top 10 Best Warehouse Management Systems In 2022

July 2, 2022
Find Old Pensions and Boost Your Retirement Income

Find Old Pensions and Boost Your Retirement Income

July 2, 2022
  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

Go to mobile version