Knowledgebase | VPSGrid
English
EnglishBeta EspañolPortuguês (Brasil)Coming soonFrançaisComing soonDeutschComing soon
Client Area

How to Change a Linux Hostname

KB-062, Linux VPS, VPSGrid, unmanaged 0 found helpful

How to Change a Linux Hostname

Short answer

Set the system hostname with hostnamectl set-hostname, update /etc/hosts so the name resolves locally, then verify with hostnamectl / hostname. This does not automatically change public DNS — point domains with A records separately.

Overview

The Linux hostname is the machine’s local name (shell prompts, some logs, internal identity). On VPSGrid it is separate from:

  • The Hostname field you may set at order time in the client area
  • Your domain name used by websites (DNS A records)
VPSGrid note

Changing the guest OS hostname does not rename the service label everywhere in billing. For public websites, always set DNS to the primary IP.

1) Check the current hostname

hostname
hostnamectl
# also useful:
hostname -f

2) Set a new hostname

Pick a simple name (letters, numbers, hyphens). Example: app1 or vps-nyc-01.

sudo hostnamectl set-hostname vps-nyc-01

# verify
hostnamectl
hostname

3) Update /etc/hosts

Ensure the name maps locally (especially important for software that looks up the hostname):

sudo nano /etc/hosts

Include a line similar to:

127.0.0.1   localhost
127.0.1.1   vps-nyc-01
# keep your primary IP mappings if present, for example:
# YOUR_PRIMARY_IP   vps-nyc-01

Save the file, then test:

getent hosts vps-nyc-01
ping -c 1 vps-nyc-01

4) Optional reboot

Most services pick up hostnamectl immediately. Reboot if a specific app still shows the old name:

sudo reboot

Important notes

  • Hostname ≠ SSL certificate name — certificates follow DNS names you configure in Nginx/Apache/IIS
  • Do not put spaces in hostnames
  • If you use mail or reverse DNS expectations, ask support whether PTR/rDNS can be set for your primary IP — that is separate from hostnamectl

Frequently Asked Questions

Will this break SSH?

No. SSH uses the primary IP (or DNS name you configured). You may see a new banner hostname after reconnecting.

Do I need to change DNS?

Only if you want visitors to reach a domain. Hostname changes inside Linux do not update public DNS A records.

Can I set a FQDN like app.example.com?

You can, but keep DNS in sync if you do. Many admins keep a short local hostname and handle public names only in DNS and web server configs.

Related Articles

Need More Help?

Open a ticket at billing.vpsgrid.net with your service ID, primary IP, and the output of hostnamectl.

Was this answer helpful?

Related Articles