How to change hostname

Hostname is the name given to your computer. Ubuntu assigns a name automatically when you are installing it. This hostname is shown in the login screen and as part of your command prompt. Changing the hostname in Linux is quite easy.

  • To set hostname temporarily until next reboot:
$ sudo hostname new-hostname-foo
  • To set the hostname permanently:
  1. Edit the /etc/hostname file and replace the current name in it with the new hostname.
  2. Edit the /etc/hosts file and replace the hostname for the IP address 127.0.1.1 with the new hostname.
  3. Restart the computer.

Tried with: Ubuntu 14.04

Advertisements

One thought on “How to change hostname

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s