Linux, OpenSource, Programming And Hacks

Jun 11, 2015

Change Computer name/hostname in ubuntu linux

Jun 11, 2015
If you didn't paid much attention to changing computer/machine name while installation and now want to change it or just want to change it. you need to edit two files /etc/hostname and /etc/hosts and replace your hostname with the new one. I will use nano editor to do so. nano is a console (terminal) based text editor, so the file will open in the terminal itself.

Simply follow these steps.

1. Open the terminal (ctrl+alt+t) and enter the following command
sudo nano /etc/hostname

you 'll be asked to input your password, after that the hostname file will open in nano editor. Now, you just have to replace your current hostname with the new one. hit ctrl+o to save and ctrl+x to exit nano editor.

2. Enter the following command to open the /etc/hosts file
sudo nano /etc/hosts

now, again find your current hostname and replace it with the new name then save and exit.


No comments:

Post a Comment