Ubuntu – changing hostname without rebooting
Posted by jpluimers on 2018/01/15
Assembled from various bits in [WayBack] How do I change the hostname without a restart? – Ask Ubuntu.
Assume your new host name is newHostName.
- edit
/etc/hostsand replace the old hostname withnewHostName - Perform these commands:
hostnamectl set-hostname newHostName
exec bash
hostname -f
Both the command prompt and the hostname output should show newHostName.
Note: if you get this when performing hostname -f then you forgot to edit /etc/hosts as per [WayBack] Just so everyone knows, the edit of /etc/hosts did the trick the 12.04 – Why I get hostname: Name or service not known error? – Ask Ubuntu:
hostname: Name or service not known
–jeroen






Leave a comment