To change host name in Linux from command line, type:
Now, you will see a file such as the one shown below:
To change the hostname , you can change the highlighted to any thing you want. Press ‘i‘ or INSERT to edit the file. After making necessary changes, you can save the file by pressing ESC followed by :wq and hit ENTER.
Now, restart to make necessary changes. You can reboot by typing the following in the command line:
After reboot, login and check your hostname by typing the following in the terminal / command line :
Hope this helps! 🙂