Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to change hostname

📅 2015-Mar-20 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ hostname ⬩ 📚 Archive

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.

$ sudo hostname new-hostname-foo
  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


© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧