--- title: "Update Host names" slug: "update-host-names" updated: 2024-10-10T09:37:46Z published: 2024-10-10T09:37:46Z canonical: "help.scalefusion.com/update-host-names" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.scalefusion.com/llms.txt > Use this file to discover all available pages before exploring further. # Update Host names Use this script to remotely update the Host names on Linux machines. 1. Copy and save the contents below to a **UTF-8** editor like **notepad++** OR **Sublime Text** in Windows or **gedit** in Ubuntu. 1. If you are using **notepad++** then use the bottom right panel to change the type to **Unix (LF)**. ![](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/image-3XNBVIR0.png) 2. Or click [here](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/Multipe_Hostname_update.sh) to download the file. ```bash #!/bin/bash # Check if the script is run with root privileges if [ "$EUID" -ne 0 ]; then  echo "Please run as root."  exit 1 fi # Get the current hostname current_hostname=$(hostname) # Check if the current hostname is empty or not if [ -z "$current_hostname" ]; then  echo "Error: Unable to retrieve current hostname."  exit 1 fi # Define the new hostname based on the current hostname case $current_hostname in  "please enter the current hostname of the machine 1")    new_hostname="please enter new hostname you want set"    ;;  "please enter the current hostname of the machine 2")    new_hostname="please enter new hostname you want set"    ;;  # Add more cases for additional hostnames  *)    # If the current hostname doesn't match any known cases, no changes are made    echo "Hostname is not in the list. No changes made."    exit 0    ;; esac # Change the hostname in /etc/hostname echo "$new_hostname" > /etc/hostname # Change the hostname in /etc/hosts sed -i "s/127.0.1.1.*/127.0.1.1\t$new_hostname/" /etc/hosts # Notify the user to reboot for the changes to take effect echo "Hostname changed from $current_hostname to $new_hostname. Please reboot your system for the changes to take effect." ``` 3. In the script, replace the following placeholder: 1. case $current_hostname in "please enter the current hostname of the machine 1") 2. new_hostname="please enter new hostname you want set" 4. The device will need to be rebooted once after publishing the script. 5. Follow [our guide](/docs/deploy-linux-shell-scripts-using-scalefusion#step-1-upload-and-deploy-the-script) to upload & publish the script using Scalefusion Dashboard. > [!CAUTION] > Note: > > 1. Some of the scripts and their contents are sourced from internet and yes, our new friend ChatGPT. > 2. Please validate the scripts on a test machine before deploying them on all your managed devices. > 3. Scalefusion has tested these scripts, however Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the usage of these scripts.