How to Change Hostname on Ubuntu 18.04
This instructional exercise will manage you through the way toward changing the hostname on a Ubuntu 18.04 framework.
The hostname is set when the Ubuntu working framework is introduced or on the off chance that you are turning up a virtual machine it is progressively relegated to the occurrence at startup.
The technique depicted in this guide will work without the need of restarting your framework.
Despite the fact that this instructional exercise is composed for Ubuntu 18.04 similar guidelines apply for Ubuntu 16.04 and any Ubuntu-based dispersion, including Linux Mint and Elementary OS.
Prior to proceeding with this instructional exercise, ensure you are signed in as a client with sudo advantages .
A hostname is a mark that distinguishes a machine on the organization. You shouldn't utilize the equivalent hostname on two unique machines on an equivalent organization.
Display the Current Hostname
To see the current hostname, enter the accompanying order:
Ubuntu 18.04 hostnamectl
As should be obvious in the picture over, the current hostname is set to ubuntu1804.localdomain.
Change the Hostname
The accompanying advances layout how to change the hostname in Ubuntu 18.04.
1. Change the hostname using
In Ubuntu 18.04 we can change the framework hostname and related settings utilizing the order hostnamectl.
For instance, to change the framework static hostname to linuxize, you would utilize the accompanying order:
sudo hostnamectl set-hostname linuxize
The hostnamectl order doesn't create yield. On progress, 0 is restored, a non-zero disappointment code in any case.
2. Edit the
Open the/and so forth/has document and change the old hostname to the enhanced one.
127.0.0.1 localhost 127.0.0.1 linuxize # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
3. Edit the
In the event that the cloud-init bundle is introduced you likewise need to alter the cloud.cfg document. This bundle is generally introduced naturally in the pictures gave by the cloud suppliers, for example, AWS and it is utilized to deal with the instatement of the cloud occurrences.
To check if the bundle is introduced run the accompanying ls order :
ls -l /etc/cloud/cloud.cfg
In the event that you see the accompanying yield it implies that the bundle isn't introduced and no further activity is required.
ls: cannot access '/etc/cloud/cloud.cfg': No such file or directory
In the event that the bundle is introduced the yield will resemble the accompanying:
-rw-r--r-- 1 root root 3169 Apr 27 09:30 /etc/cloud/cloud.cfg
For this situation you'll have to open the/and so on/cloud/cloud.cfg record:
sudo vim /etc/cloud/cloud.cfg
Quest for preserve_hostname and change the incentive from bogus to valid:
# This will cause the set+update hostname module to not operate (if true) preserve_hostname: true
Save the document and close your proofreader.
Verify the change
To confirm that the hostname was effectively changed, by and by utilize the hostnamectl order:
Static hostname: linuxize Icon name: computer-vm Chassis: vm Machine ID: 6f17445f53074505a008c9abd8ed64a5 Boot ID: 1c769ab73b924a188c5caeaf8c72e0f4 Virtualization: kvm Operating System: Ubuntu 18.04 LTS Kernel: Linux 4.15.0-22-generic Architecture: x86-64
You should see your new worker name imprinted on the support.
In this instructional exercise, we have told you the best way to handily change your Ubuntu worker hostname without restarting the machine.
Don't hesitate to leave a remark in the event that you have any inquiries.
Particle is an open-source cross-stage code manager created by GitHub. It has an inherent bundle chief, inserted Git control, keen autocompletion, ...
An HTML editor is a software for enhancing HTML, the markup of an internet web page. It stands for Tiny Moxiecode Content Editor. TinyMCE is a effe...
Redis is an open-source in-memory key-esteem information store. It tends to be utilized as an information base, store and, message representative, ...
phpMyAdmin is an open-source PHP based instrument for overseeing MySQL and MariaDB workers over an online interface. phpMyAdmin permits you ...
While diverting the yield of an order to a document or funneling it to another order, you may see that the blunder messages are imprinted on the sc...
Deb is the establishment bundle design utilized by all Debian based dispersions. The Ubuntu vaults contain a huge number of deb bundles that...
CodeIgniter Subquery: This tutorial will explain you how to write subquery in codeigniter using active records. SubQuery is a query ...
Hi! In this tutorial we'll see how to find codeigniter version you are using. For pros it may sound basic but would be a challenge fo...
R is an open-source programming language and free climate that has practical experience in factual figuring and graphical portrayal. It is principa...
FTP (File Transfer Protocol) is a standard customer worker network convention that permits clients to move documents to and from a distant organiza...
Cup is a free and open-source miniature web system for Python intended to assist engineers with building secure, adaptable and viable web applicati...
Docker Compose is an instrument that permits you to characterize and arrange multi-holder Docker applications. It utilizes a YAML document to arran...
Spotify is a computerized music real time feature that gives you moment admittance to a great many melodies, from old works of art to the most rece...
sudo is an order line program that permits confided in clients to execute orders as root or another client. In this article we'll show b...
PHP is one of the most utilized worker side programming dialects. Numerous well known CMS and structures, for example, WordPress, Magento, and Lara...
Apache Maven is an open-source venture the executives and perception device utilized principally for Java ventures. Expert uses a Project Object Mo...
twist is an order line utility for moving information from or to a far off worker. With twist, you can download or transfer information utilizing o...
Vim/Vi is the word processor of decision for some product designers and Linux framework chairmen. As a matter of course, Vim doesn't sho...
Trade is a space on a plate that is utilized when the measure of actual RAM memory is full. At the point when a Linux framework runs out of RAM, in...