Ubuntu Google Authenticator

A hostname basically is the computer’s name. It’s used in identifying the computer on a network. It is shown visibly in the terminal. The hostname can be changed to anything one wants, however one cannot use the same hostname on two different computers on a network, as it can be deemed to cause problems. So how do you change the hostname in Ubuntu? Read on to know how you can do it.

The following steps will give your computer a new identity in no time.

  1. Open the terminal window to get started.

Click the ubuntu button to pull up the dash and search for Terminals. To change the hostname you will have to edit the hostname file location. Run the command in the terminal to open the hostname file.

sudo gedit / etc / hostname

One can also use other terminal-based editors like nano or vi for this.

  1. The hostname file will open and will display the current computer name.  To change the hostname, delete the existing hostname from the file and replace it with the desired new name.
  2. Then save the text file.
  3. Close all open windows and restart your system. The change of the hostname will not take immediate effect as you will have to reboot or use the hostname command to change it immediately.

This command will only change the hostname till the next time the computer is rebooting, to permanently change the hostname file one has to change the /etc/hostname file. The hostname is stored in the / etc / host file too where it is to redirect to the local computer. The hostname needs to be changed in the host file, too.

  1. Open the host files with a command like:

sudo gedit / etc/hosts

One can also use other terminal-based editors like nano or vi of their choice.

  1. Once you locate the host file, replace the old hostname with the new hostname.
  2. Save the /etc/ hosts file

After configuring everything, all that is needed is to restart the computer and check to ensure that the hostname has been updated. The computer hostname will be changed immediately but the change will not appear in the terminal immediately.

And there you go, the hostname is changed, it is easy as long as you follow the steps correctly. You can do it without professional consultancy as the steps are not complicated.

Leave a Reply