How to change a server's hostname: Difference between revisions

From Wiki
Jump to navigation Jump to search
Created page with 'Update the following files: * /etc/hosts * /etc/hostname'
 
No edit summary
Line 2: Line 2:
* /etc/hosts
* /etc/hosts
* /etc/hostname
* /etc/hostname
== Ubuntu 18.04 ==
See current hostname and related info:
<pre>
hostnamectl
</pre>
Change hostname:
<pre>
hostnamectl set-hostname my_new_hostname
</pre>
Update <code>/etc/hosts</code> if necessary.
If <code>cloud-init</code> is installed, edit <code>/etc/cloud/cloud.cfg</code>
<pre>
preserve_hostname: true
</pre>

Revision as of 19:38, 24 January 2019

Update the following files:

  • /etc/hosts
  • /etc/hostname

Ubuntu 18.04

See current hostname and related info:

hostnamectl

Change hostname:

hostnamectl set-hostname my_new_hostname

Update /etc/hosts if necessary.

If cloud-init is installed, edit /etc/cloud/cloud.cfg

preserve_hostname: true