Editing /etc/hostname and /etc/hosts - recommended?
I've cloned a linux (ubuntu 20.04) workstation.
I think I need to edit /etc/hosts and /etc/hostname to rename the cloned disk.
Is there anything else I need to change/edit?
or is it better to use the hostname command?
Thanks
LinuxLinux NetworkingUbuntuLinux OS DevLinux Distributions
Last Comment
David Favor
8/22/2022 - Mon
Seth Simmons
using either hostname command or modifying the files manually is fine the hostname command just makes it easier for those who don't know how to change manually don't forget to change the IP address (if not using DHCP)
Dwight Baer
ASKER
Thanks Seth. I was just sortof double-checking. But I'll leave this open until tomorrow in case somebody knows of anything else I should check. I'm using DHCP; it's not a server or anything in need of a static IP address.
noci
The hostname file is used to setup the new systemname after boot. so it will provide a new hostname. /etc/hosts needs to contain the hostname as self reference for Debian systems to it need to stay in sync. Check that your system has a different MAC address.. (unless the real system isn;t used anymore then there is no noeed to change anything and you may actually need to ensure it has the same MAC address).
So 127.0.0.1 returns for the fully qualified hostname + also the short hostname.
If you have a local DNS caching server running, likely this is overkill + if not, this will make a big difference when you're doing command line work where you reference your own machine name.
Er... There was a typo above... Should be 127.0.0.1 so 127.0.1.X crept into my script at some point...
To many long nights working on hosting problems + email delivery/inboxing problems... :-)
the hostname command just makes it easier for those who don't know how to change manually
don't forget to change the IP address (if not using DHCP)