Ubuntu: Permanent hostname change on Ubuntu


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"     <new.hostname>  

How can I make this permanent?


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
Next Post »