Ubuntu 18.04 LTS change hostname completely
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 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
Discover your public or non-public IP tackle by operating the ip command:
$ ip a
$ ip a s eth0
2: eth0:
hyperlink/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 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 192.168.2.24 utilizing a textual content editor similar to vim command/nano command:
$ sudo vi /and so on/hosts
OR
$ sudo nano /and so on/hosts
Replace/append:
192.168.2.24 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.
Conclusion
You realized find out how to change hostname completely when utilizing Ubuntu 18.04 LTS as per your wants.