Steps to do when renaming a Linux host:

  1. Edit /etc/hostname
  2. Edit /etc/hosts
  3. Edit /etc/mailname
  4. Possibly generate a new ssh host key. See /var/lib/dpkg/info/openssh-server.postinst (function create_keys) for details on how to do that.
  5. sudo grep -r $OLDNAME /etc

If you’re copying a virtual machine using virt-clone, you may want to do these as well:

  1. Edit the xml file to update the <graphics> port attribute be unique.
  2. If the emulated network card’s MAC address has changed, edit /etc/udev/rules.d/70-persistent-net.rules accordingly, otherwise udev will rename it to a new name, and network might not work.