Ubuntu – How to Change Hostname Without Rebooting

1. Update the current hostname

This command will instantly update the hostname which prevents having to reboot. It is not, however, persistent so your changes will be lost the next time you do reboot.

2. Update hostname File

Delete the current hostname and replace it with yours. This makes the new hostname persist when you reboot.

3. Update hosts File

If the new hostname isn’t added to the hosts file the sudo command won’t function properly.

Add the following on a new line after the localhost line:

Your hosts file should look similar to the following:

Leave a Reply

Your email address will not be published. Required fields are marked *

×Mike Everhart

Need Some More Help? Let's Talk!

I'd love to work with you! Fill out the form below to schedule a free consultation to discuss your needs and how I can help.

Need More Help?