How do I assign a static hostname to a Paperspace Linux instance?

tutorial

#1

Issue

Paperspace hostnames are auto-generated and dynamically assigned when the instance is provisioned. If you change the hostname of a Linux instance using the standard hostname command, the new hostname will reset if you start/stop or reboot the instance. This guide will enable you to set a static hostname that persists across reboots.

Resolution

  1. Update the /etc/hosts file on your Linux instance with the new hostname.
    sudo vim /etc/hosts

    Change the name associated with the IP address 127.0.0.1 to the hostname that you want the instance to use even after a reboot. Typically this involves changing localhost to the new hostname.
    127.0.0.1 new_hostname

  2. Update the /etc/hostname file on your Linux instance with the new hostname.
    sudo vim /etc/hostname

  3. If you have not already done so, run the Linux hostname command and specify the new hostname if you want to begin using the new hostname without restarting.
    sudo hostname new_hostname

Test

  1. The next time that you restart or reboot the instance, run the Linux hostname command again to verify that the hostname change persisted.
    hostname

    The command should return the new hostname.
    new_hostname