Change a hostname in Ubuntu server is very easy. From the command line terminal, type hostname newname. View the new hostname with hostname command. See the step by step example on how to change Ubuntu server hostname below:
- View current hostname:
- master@SVR01:~$ hostname
- SVR01
- Change hostname and view latest hostname:
- master@SVR01:~$ sudo hostname Ubuntu
- master@SVR01:~$ hostname
- Ubuntu
Don't fall for it. That doesn't change anything. The hostname is still the same as you can see at the prompt. Even reboot won't change anything. The exact method to change the hostname permanently is by editing /etc/hostname file. Here is the step:
- Open /etc/hostname with your favorite text editor:
- master@SVR01:~$ sudo nano /etc/hostname
- master@SVR01:~$ sudo shutdown now -r
Now you can change hostname and save. The changed is permanent even after you reboot your system.
No comments:
Post a Comment