← Volver al blog

How to Change Hostname in Linux

  • Xernode
  • 1 min de lectura
  • 3 de abril de 2026
Web Hosting linux server hostname configuration sysadmin

Introduction

Changing the hostname of your Linux server helps with identification and organization, especially in multi-server environments. This guide shows you how to change the hostname safely.

Step-by-step Guide

  1. Check the current hostname
    • hostname
  2. Set the new hostname (temporary, until reboot)
    • sudo hostnamectl set-hostname new-hostnamen
      • (Replace new-hostname with your desired hostname)
  3. Edit the /etc/hosts file to update the hostname
    • sudo nano /etc/hostsn
      • Find the line with 127.0.1.1 and replace the old hostname with the new one:
    • 127.0.1.1 new-hostname
  4. (Optional) Edit /etc/hostname for older systems
    • sudo nano /etc/hostnamen
      • Replace the old hostname with the new one and save.
  5. Reboot the server to apply all changes
    • sudo reboot
  6. Verify the new hostname after reboot
    • hostname

Recommendations

  • Use descriptive hostnames for easier server management.
  • Update DNS records if your hostname is used in your network.
  • Always double-check /etc/hosts to avoid SSH or mail issues.

Call To Action

eed reliable Linux hosting for your projects? Check out our VPS plans! https://xernode.com/#pricing

Related Guides