How to change the hostname of your linux virtual nodes india

    Posted in Linux Servers on Oct 11, 2018

    Change Virtual Compute Nodes Hostname

    Please follow the below steps to change the hostname of your Virtual Compute Node.

    Login to your Virtual Compute Node as a root user.

    To check the current hostname of your server, run the command


    To change the hostname of your server, type new name followed by hostname

    hostname new-name

    Change the hostname under the path /etc/sysconfig/network

    vi /etc/sysconfig/network

    Edit the content of the file so that it looks like this



    Next, edit the /etc/hostname file and update hostname:

    vi /etc/hostname

    Edit the /etc/hosts file and update your old-host-name:

    vi /etc/hosts

    Immediately after executing the previous command, the hostname is changed, but the change will last only until the next reboot. To permanently change the hostname, the next step is to run the following command in your terminal

    cd /etc/one-context.d/

    This will take you inside the directory one-context.d

    List the contents of the directory by running the following command,

    ls -la

    You will see the following result

    drwxr-xr-x  2 root root 4096 Oct 26 19:48 .
    drwxr-xr-x 72 root root 4096 Jan 21 15:04 ..
    -rwxr-xr-x  1 root root 4433 Jan 15  2015 00-network
    -rwxr-xr-x  1 root root 1991 Jan 15  2015 01-dns
    -rwxr-xr-x  1 root root 1720 Jul 12  2016 02-ssh_public_key
    -rwxr-xr-x  1 root root   28 Jan 15  2015 03-selinux-ssh
    -rwxr-xr-x  1 root root   15 Jan 15  2015 04-mount-swap
    -rwxr-xr-x  1 root root  614 Jan 15  2015 05-hostname
    -rwxr-xr-x  1 root root  297 Jan 15  2015 99-execute-scripts

    We need to move the directory 05-hostname to root folder. To execute this run the following command in the terminal.

    mv 05-hostname /root/

    Now your hostname is changed permanently. linux-dedicated-seerver.jpg