Ubuntu: Permanent hostname change on Ubuntu



Question:

I have successfully changed the hostname of my Ubuntu machine, though whenever I restart it, I need to run this command to access it using host nname

sudo /etc/init.d/hostname.sh start

This is what I used to do the change:

# take care of "hostname" command and editing "/etc/hostname"  hostnamectl set-hostname <new.hostname>  # Edit "/etc/hosts"  127.0.1.1     <new.hostname>  

How can I make this permanent?


Solution:1

Edit the file /etc/hostname.

From man 5 hostname:

It should contain a single newline-terminated hostname string.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »