Ubuntu 18.04 LTS change hostname completely


Get real time updates directly on you device, subscribe now.

I am a brand new Ubuntu Linux 18.04 LTS cloud server person. By default my serer identify to ‘localhost’ throughout set up however now I want to change the pc identify to ‘u1804-nixcraft’. Are you able to inform me how do I take away localhost and set it to u1804-nixcraft on Ubuntu 18.04 Linux? How do I alter the Ubuntu laptop identify from ‘localhost’ to ‘u1804-nixcraft’? Are you able to inform me extra about Ubuntu Linux change hostname command?

It’s essential use the hostnamectl command to see or set the Ubuntu 18.04 LTS system’s host identify. The host identify or laptop identify is often at system startup in /and so on/hostname file. Open the terminal software and sort the next instructions to set or change hostname or laptop identify on Ubuntu.

The right way to show the present Ubuntu hostname

Merely kind the next command:
$ hostnamectl
Ubuntu 18.04 LTS see current hostname command

Ubuntu 18.04 LTS change hostname completely

The process to vary the pc identify on Ubuntu 18.04 LTS:

Kind the hostnamectl command :
sudo hostnamectl set-hostname newNameHere
Delete the previous identify and setup new identify.Subsequent Edit the /and so on/hosts file:
sudo nano /and so on/hosts
Change any incidence of the prevailing laptop identify together with your new one.Reboot the system to modifications take impact:
sudo reboot

The right way to change hostname on Ubuntu 18.04 and not using a system restart

Allow us to see present setting simply kind the next command:
$ hostnamectl
Subsequent change hostname from localhost to u1804-nixcraft, enter:
$ hostnamectl set-hostname u1804-nixcraft
Confirm new modifications:
$ hostnamectl
Ubuntu 18.04 LTS change hostname permanently
Discover your public or non-public IP tackle by operating the ip command:
$ ip a
$ ip a s eth0

2: eth0: mtu 1500 qdisc fq_codel state UP group default qlen 1000
hyperlink/ether 40:9f:38:28:f6:b5 brd ff:ff:ff:ff:ff:ff
inet brd scope world noprefixroute enp6s0
valid_lft perpetually preferred_lft perpetually
inet6 fe80::429f:38ff:fe28:f6b5/64 scope hyperlink
valid_lft perpetually preferred_lft perpetually

Replace /and so on/hosts file with that IP tackle similar to utilizing a textual content editor similar to vim command/nano command:
$ sudo vi /and so on/hosts
$ sudo nano /and so on/hosts
Replace/append: u1804-nixcraft
Be sure to change any incidence of the previous laptop identify together with your new one too. Save and shut the file in vim.


You realized find out how to change hostname completely when utilizing Ubuntu 18.04 LTS as per your wants.

Posted by: Vivek Gite

The writer is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a coach for the Linux working system/Unix shell scripting. Get the newest tutorials on SysAdmin, Linux/Unix and open supply subjects through RSS/XML feed or weekly electronic mail publication.

Source link

Leave A Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More