{"id":929,"date":"2026-10-26T09:00:00","date_gmt":"2026-10-26T09:00:00","guid":{"rendered":"https:\/\/vpslake.com\/blog\/?p=929"},"modified":"2026-10-26T09:00:00","modified_gmt":"2026-10-26T09:00:00","slug":"change-hostname-ubuntu-25-10","status":"publish","type":"post","link":"https:\/\/vpslake.com\/blog\/2026\/10\/26\/change-hostname-ubuntu-25-10\/","title":{"rendered":"How to Change Hostname on Ubuntu 25.10"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To change hostname on Ubuntu 25.10, set the system name with <code>hostnamectl<\/code> and update Ubuntu&#8217;s local name mapping. You will have a persistent, locally resolvable hostname in about five minutes, without rebooting the VPS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Ubuntu 25.10 (Questing Quokka) installed on the VPS.<\/li>\n\n\n<li>An SSH session as <code>root<\/code>, or a normal user with working <code>sudo<\/code> access.<\/li>\n\n\n<li>A new hostname such as <code>web01<\/code> or <code>web01.example.com<\/code>, using lowercase letters, numbers, hyphens, and dots only.<\/li>\n\n\n<li>Access to your DNS provider and the server&#8217;s public IP if other machines must resolve an FQDN. No special RAM or disk allocation is needed for this change.<\/li>\n\n\n<li>A <a href=\"https:\/\/vpslake.com\/buy-vps\">VPSLake Linux VPS<\/a> with Ubuntu 25.10 if you need a server for the procedure.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Record the current hostname<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the release and each hostname type first so you can distinguish the saved name from a temporary value supplied by networking or the VPS image.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/os-release\nhostnamectl --static\nhostnamectl --transient\nhostnamectl --pretty\nhostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The release file should identify Ubuntu 25.10. Blank transient or pretty values are normal. A sample result may look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRETTY_NAME=\"Ubuntu 25.10 (Questing Quokka)\"\nold-node.example.com\nold-node.example.com\n\nold-node.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The static hostname is the durable operating-system value you will change. The transient name can come from DHCP or metadata, while the pretty name is only an optional description.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Set the persistent hostname<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>hostnamectl<\/code> changes the active hostname and writes the persistent <code>\/etc\/hostname<\/code> value through systemd, keeping the current session and the next boot aligned.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo hostnamectl set-hostname NEW_HOSTNAME\nhostnamectl --static\ncat \/etc\/hostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>NEW_HOSTNAME<\/code> with a short name or FQDN, such as <code>web01.example.com<\/code>. Do not use spaces, underscores, or a trailing dot. Static names are limited to valid DNS-style characters and 64 characters; the <a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/latest\/hostnamectl.html\" target=\"_blank\" rel=\"noopener\">systemd hostnamectl documentation<\/a> explains the distinction between static, transient, and pretty hostnames.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Both checks should now print the new value, and the command normally produces no success message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>web01.example.com\nweb01.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you want a human-readable label in addition to the machine name, set it independently. This optional value may contain spaces and is not used for DNS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo hostnamectl set-hostname \"NEW_PRETTY_NAME\" --pretty\nhostnamectl --pretty<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example, <code>NEW_PRETTY_NAME<\/code> could be <code>Production web server<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Make the new name resolve locally<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Changing the system name does not automatically update <code>\/etc\/hosts<\/code>, so local programs can still resolve the old name or return <code>localhost<\/code> until you correct that mapping.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/hosts<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Keep the existing <code>127.0.0.1 localhost<\/code> and IPv6 records. Replace an old <code>127.0.1.1<\/code> machine-name line, or add one if it is missing. For an FQDN, use this format:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.1.1 NEW_HOSTNAME NEW_SHORT_NAME<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For <code>web01.example.com<\/code>, the short alias is <code>web01<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.1.1 web01.example.com web01<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you chose only <code>web01<\/code>, use <code>127.0.1.1 web01<\/code>. Keep one machine-name entry rather than leaving both the old and new lines in place. This pattern keeps the server&#8217;s own name available locally without depending on public DNS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test the resolver after saving the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getent hosts NEW_HOSTNAME\nhostname --fqdn\nhostname -s<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For the example FQDN, successful output is similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.1.1       web01.example.com web01\nweb01.example.com\nweb01<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The hosts file affects this VPS only. Create an A or AAAA record with your DNS provider if laptops, monitoring systems, or other servers must resolve the name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Prevent cloud-init from undoing the change<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some VPS images use cloud-init to apply a provider-supplied hostname during boot, so check whether it is installed before changing any cloud configuration.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if command -v cloud-init &gt;\/dev\/null 2&gt;&amp;1; then\n  cloud-init status --long\nelse\n  echo \"cloud-init is not installed\"\nfi<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If cloud-init is absent, continue to Step 5. If it is installed and the new name remains after a reboot, no adjustment is needed. If it restores the old name, add a small drop-in that preserves the local setting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo install -d -m 0755 \/etc\/cloud\/cloud.cfg.d\nprintf '%s\\n' 'preserve_hostname: true' | sudo tee \/etc\/cloud\/cloud.cfg.d\/99-preserve-hostname.cfg\nsudo hostnamectl set-hostname NEW_HOSTNAME<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>tee<\/code> command should echo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>preserve_hostname: true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/docs.cloud-init.io\/en\/latest\/reference\/modules.html\" target=\"_blank\" rel=\"noopener\">cloud-init module reference<\/a> documents <code>preserve_hostname<\/code>. If the provider continues to apply a hostname from instance metadata, update that provisioning value as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Refresh your SSH session<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The new name is active immediately, but an existing shell prompt may have been created with the old value. Confirm the live and persistent settings, then open a second SSH session.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hostname\nhostnamectl --static\ncat \/etc\/hostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">All three lines should contain the chosen hostname:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>web01.example.com\nweb01.example.com\nweb01.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Most applications do not need a restart for this change. Restart an individual service only when that application reads the hostname once at startup, using its actual unit name rather than guessing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart YOUR_SERVICE<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>YOUR_SERVICE<\/code> with a real service you administer. Do not restart networking or reboot solely to apply the hostname.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the new hostname<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run this final group to confirm the static name, short name, fully qualified result, and local resolver entry:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hostnamectl --static\nhostname -s\nhostname --fqdn\ngetent hosts NEW_HOSTNAME<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For <code>web01.example.com<\/code>, the first three lines should be <code>web01.example.com<\/code>, <code>web01<\/code>, and <code>web01.example.com<\/code>. The last line should return the <code>127.0.1.1<\/code> mapping or the expected DNS address. When those values agree, Ubuntu 25.10 is using the new hostname consistently.<\/p>\n\n\n\n<aside class=\"vl-element vl-cta-banner\" aria-label=\"Set a clear server identity\">\n\t<div class=\"vl-cta-banner__content\">\n\t\t<p class=\"vl-cta-banner__eyebrow\">Ubuntu VPS<\/p>\n\t\t<h3 class=\"vl-cta-banner__title\">Set a clear server identity<\/h3>\n\t\t<p class=\"vl-cta-banner__text\">Deploy an Ubuntu 25.10 VPS with root access for clean hostname and DNS configuration.<\/p>\n\t<\/div>\n\t<a class=\"vl-cta-banner__button\" href=\"\/buy-vps\" aria-label=\"View Linux VPS plans\">View Linux VPS plans<\/a>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><code>hostnamectl: invalid hostname<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The static name contains a character Ubuntu rejects, commonly a space, underscore, or trailing dot. Use lowercase letters, numbers, hyphens, and dots in <code>NEW_HOSTNAME<\/code>; put spaces only in <code>NEW_PRETTY_NAME<\/code>. Also check that every FQDN label starts and ends with a letter or number.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>hostname --fqdn<\/code> still shows the old name<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The active hostname changed, but <code>\/etc\/hosts<\/code> still contains the previous <code>127.0.1.1<\/code> entry or has duplicate machine-name lines. Replace the stale line, keep one mapping for the new name, and run <code>getent hosts NEW_HOSTNAME<\/code> again. If only remote systems see the old name, update public DNS and allow its cached record to expire.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The old hostname returns after reboot<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cloud-init, DHCP metadata, or the VPS image is applying a name during startup. Check <code>cloud-init status --long<\/code>, add the <code>99-preserve-hostname.cfg<\/code> drop-in from Step 4 when cloud-init is responsible, and update the provider&#8217;s provisioning hostname if it continues to overwrite the local setting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>sudo: a password is required<\/code> or <code>Access denied<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The current account lacks the privilege needed to change the system name. Run the command with <code>sudo<\/code> after authenticating, verify that <code>sudo -v<\/code> succeeds, or reconnect as <code>root<\/code>; changing permissions on <code>\/etc\/hostname<\/code> is not a safe workaround.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Next steps<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Add and test the public A or AAAA record if the hostname will be used by websites, TLS, mail, or monitoring.<\/li>\n\n\n<li>Request a matching PTR record through the system that manages your VPS IP when reverse DNS matters.<\/li>\n\n\n<li>Update SSH inventory, backups, monitoring, certificates, and configuration-management records that still use the old name.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Can I change the hostname while connected over SSH?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The current SSH connection normally stays open because changing the hostname does not restart the network or SSH daemon. Open a new session afterward so your shell prompt is built with the new name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I use a short hostname or an FQDN?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A short name such as <code>web01<\/code> is fine for a standalone VPS or private network. Use an FQDN when TLS, mail, monitoring, or multi-server tools need a unique identity, and make sure it resolves through <code>\/etc\/hosts<\/code> or public DNS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does this rename my VPS in the client area or update reverse DNS?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. <code>hostnamectl<\/code> changes Ubuntu&#8217;s local operating-system identity only. The VPS label, public DNS record, and PTR record are separate settings managed in their respective systems.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between a static and pretty hostname?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The static hostname is the operational name stored in <code>\/etc\/hostname<\/code> and used by system services. A pretty hostname is an optional human-readable label that can contain spaces; it does not replace the static name or publish DNS.<\/p>\n\n\n\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Can I change the hostname while connected over SSH?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Yes. The current SSH connection normally stays open because changing the hostname does not restart the network or SSH daemon. Open a new session afterward so your shell prompt is built with the new name.\"}}, {\"@type\": \"Question\", \"name\": \"Should I use a short hostname or an FQDN?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"A short name such as `web01` is fine for a standalone VPS or private network. Use an FQDN when TLS, mail, monitoring, or multi-server tools need a unique identity, and make sure it resolves through `\/etc\/hosts` or public DNS.\"}}, {\"@type\": \"Question\", \"name\": \"Does this rename my VPS in the client area or update reverse DNS?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. `hostnamectl` changes Ubuntu's local operating-system identity only. The VPS label, public DNS record, and PTR record are separate settings managed in their respective systems.\"}}, {\"@type\": \"Question\", \"name\": \"What is the difference between a static and pretty hostname?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"The static hostname is the operational name stored in `\/etc\/hostname` and used by system services. A pretty hostname is an optional human-readable label that can contain spaces; it does not replace the static name or publish DNS.\"}}]}<\/script>\n\n","protected":false},"excerpt":{"rendered":"Change hostname on Ubuntu 25.10 with hostnamectl, update \/etc\/hosts, preserve it through cloud-init, and verify the new name without rebooting.","protected":false},"author":1,"featured_media":930,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[5,9],"tags":[106,93,103],"class_list":["post-929","post","type-post","status-publish","format-standard","has-post-thumbnail","category-guides","category-vps-hosting","tag-hostname","tag-linux-vps","tag-ubuntu-25-10","cs-entry"],"_links":{"self":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/comments?post=929"}],"version-history":[{"count":1,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/929\/revisions"}],"predecessor-version":[{"id":3741,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/929\/revisions\/3741"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media?parent=929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/categories?post=929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/tags?post=929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}