Skip to main content

Changing the host name on Ubuntu 18.04

I cloned an Ubuntu 18.04 Server instance post which I wished to change the hostname of the new instance. What was supposed to be a simple operation of updating the hostname in the /etc/hostname and running sudo hostname <new hostname> didn't work as expected. The hostname used to revert on reboot. It took me quite some time to arrive at the right solution. An Ask Ubuntu answer set me in the right direction though it did not work as-is. The reason is the shipment of cloud-init in Ubuntu 18.04. I got it to work with the following steps - 

The Procedure

Step 1

Edit the cloud.cfg file present in /etc/cloud to set preserve_hostname to true. 
sudo sed 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfg

Step 2

Edit the /etc/hostname file and set the desired hostname in it.
sudo vi /etc/hostname

Step 3

Use hostnamectl to set the hostname. The new name would persist on reboots.
sudo hostnamectl set-hostname <new name>

Comments

Popular posts from this blog

Resolving INS-20802: Oracle Net Configuration Assistant failed error on Windows 10

I was all excited about the migration to Windows 10 until I had to install Oracle client 12.1.0.2 on it. The Oracle client installation used to fail miserably at the last stage with this error named INS-20802.

Turning off a Dell Laptop Monitor: Keyboard shortcut(s)

I am someone who is particular about power savings and I don't leave appliances powered on when not in use. The same applies to computing devices - be it a smartphone or a PC/Laptop. I power off the desktop monitor when I step out for a tea break or hit Fn+F2 on my Lenovo laptop that turns off the display. Recently, I got a Dell Laptop and I was surprised to discover that Dell does not provide any shortcut to turn off the display. This led to some exploration and I found two ways to achieve that which are outlined below - 

The Mutual Fund Mandate Conundrum

I always use the biller option in net banking to set up mutual fund SIPs. This time I was set to help an elderly gentleman to set up a SIP in a scheme run by UTI Mutual fund and that led me to write this post - one after several months in this blog! He has his savings account with a PSU - Canara Bank and I must say that is one tough bank to deal with. Every update requires a branch visit and they charge for literally everything - even for mobile number and email ID updates, separately. It cost us ₹59/- including GST. Tip : If you are unable to reset your net banking password for Canara Bank due to your date of birth not being registered with them, use the Unix default - 01 January 1970!