# How to Assign or Unassign a Hostname Machines are Linux and Windows virtual machines with persistent storage, GPU options, and free unlimited bandwidth. They’re designed for high-performance computing (HPC) workloads. You can assign or unassign a persistent hostname on Linux- and Windows-based machines. Persistent hostnames remain the same even after the machine shuts down or restarts. ## Get the Machine’s IP Address To assign a hostname, you first need the IP address of your machine. In the [Paperspace console](https://console.paperspace.com), in the top-left corner, click the drop-down menu and select **CORE**. Click the **Machines** tab, then find and select the machine that you need the IP address for. On the machine’s overview page, click the **Details** tab. On the right, under **Public IP** (if your machine is public) or **Private IP** (if your machine is private) section, your machine’s IP address is listed. ## Assign a Hostname for Linux-based Machines Once you have the IP address of your machine, need to [connect to your machine](https://docs.digitalocean.com/products/paperspace/machines/how-to/connect/index.html.md) and follow the instructions below for Linux machines. ### On Linux-based Machines In your machine, open a terminal, then open the `/etc/hosts` file with a text editor of your choice. ```sh sudo nano /etc/hosts ``` In `/etc/hosts`, look for the `localhost` entry and update it to use your new hostname and the IP address of your machine. If there isn’t a `localhost` entry, add one on a new line. ```text 198.51.100.0 localhost your-new-hostname ``` Then, save and exit the file. If system updates affect `/etc/hosts` or the hostname utility, you must re-add your hostname. For more information about the hosts file on Linux, see [the hosts file man page](https://manpages.ubuntu.com/manpages/bionic/en/man5/hosts.5.html). Then, set your new hostname by running the `hostnamectl` command with your new hostname. ```sh sudo hostnamectl set-hostname your-new-hostname ``` In the Paperspace console, in your machine’s overview page, click **RESTART** to apply your hostname changes to your machine. Then, [reconnect to your machine](https://docs.digitalocean.com/products/paperspace/machines/how-to/connect/index.html.md), open a terminal, and run the `hostname` command to verify that the hostname change persisted. The command should output the new hostname you added. ## Assign a Hostname for Windows-based Machines The hosts file on Windows-based machines is `C:\Windows\System32\drivers\etc\hosts`. You can’t directly modify the hosts file within the system directory, so you first need to copy it to a location where you can edit it, like your desktop: ```shell copy C:\Windows\System32\drivers\etc\hosts Desktop\hosts ``` Open the hosts file using a text editor of your choice. ```shell notepad Desktop\hosts ``` Add your new hostname to the hosts file by adding the new hostname alongside the IP address of your machine. ```text 198.51.100.0 your-new-hostname ``` After you’ve added your new hostname, save and exit the file. Then, copy the modified hosts file back into the system directory, which replaces the old hosts file. ```shell move /Y Desktop\hosts C:\Windows\System32\drivers\etc\hosts ``` In the Paperspace console, in your machine’s overview page, click **RESTART** to apply your hostname changes to your machine. Then, reconnect to your machine, open a terminal, and run the `ping` command with your new hostname to verify that the hostname change persisted. The command should output the new hostname you added. ```shell ping your-new-hostname ``` ## Unassign a Hostname If you want to unassign a hostname on your machine, you need to follow the steps for assigning a hostname for either your [Linux-based machine](#assign-a-hostname-for-linux-based-machines-assign) or [Windows-based machine](#assign-a-hostname-for-windows-based-machines), except instead of adding a new hostname, you remove the hostname you want to unassign to your machine from the hosts file.