First things

Change the computer's name

Give your machine a proper name, so it's easy to spot on the network and in SSH.

Fill these in once
  1. Set all three names macOS usesNeeds sudo
    Terminal
    sudo scutil --set ComputerName "my-laptop"
    sudo scutil --set LocalHostName "my-laptop"
    sudo scutil --set HostName "my-laptop"

Check it worked

  1. Check the new name
    Terminal
    scutil --get ComputerName && hostname
  1. Set the new nameNeeds sudo
    Terminal · Ubuntu / Debian
    sudo hostnamectl set-hostname my-laptop
  2. Update the hosts file to matchNeeds sudo
    Terminal · Ubuntu / Debian
    sudo sed -i "s/^127.0.1.1.*/127.0.1.1\tmy-laptop/" /etc/hosts

    Stops "unable to resolve host" warnings after the rename.

Check it worked

  1. Check the new name
    Terminal · Ubuntu / Debian
    hostnamectl
  1. Rename and restartRun as administrator
    PowerShell
    Rename-Computer -NewName "my-laptop" -Restart

    Your PC restarts straight away. Save your work first.

Check it worked

  1. Check the new name
    PowerShell
    hostname