{"id":909,"date":"2026-10-23T18:00:00","date_gmt":"2026-10-23T18:00:00","guid":{"rendered":"https:\/\/vpslake.com\/blog\/?p=909"},"modified":"2026-10-23T18:00:00","modified_gmt":"2026-10-23T18:00:00","slug":"change-hostname-almalinux-8","status":"publish","type":"post","link":"https:\/\/vpslake.com\/blog\/2026\/10\/23\/change-hostname-almalinux-8\/","title":{"rendered":"How to Change Hostname in AlmaLinux 8 (Step-by-Step)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Change hostname in AlmaLinux 8 with <code>hostnamectl<\/code>, a matching local hosts entry, and a few checks that catch incomplete changes. The update usually takes less than five minutes and does not require a reboot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>An AlmaLinux 8 VPS with root access or a user who can run commands with <code>sudo<\/code>.<\/li>\n\n\n<li>An SSH session to the server and a text editor such as <code>nano<\/code>.<\/li>\n\n\n<li>A new short hostname such as <code>web01<\/code>, or an FQDN such as <code>web01.example.com<\/code>; use lowercase letters, digits, hyphens, and dots only.<\/li>\n\n\n<li>The server&#8217;s primary IP address if you want the new FQDN to resolve locally, plus access to your domain&#8217;s DNS records if other machines must resolve it.<\/li>\n\n\n<li>A <a href=\"https:\/\/vpslake.com\/buy-vps\">VPSLake Linux VPS<\/a> with AlmaLinux 8 if you need a fresh server for this procedure.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Inspect the current name<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check each hostname type before changing anything so you can tell whether an old value is coming from the static configuration, the current kernel state, or a descriptive label.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/almalinux-release\nhostnamectl status --static\nhostnamectl status --pretty\nhostnamectl status --transient\nnmcli general hostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The release line should identify AlmaLinux 8. The static or transient checks may be empty on a minimally configured VPS, which is not an error. A populated result might look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AlmaLinux release 8.x\nold-web.example.com\n\nold-web.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The static hostname is the value you normally want to set permanently. The pretty hostname is optional and is meant for a human-readable description, not for DNS or service identity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Set the static hostname<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>hostnamectl<\/code> instead of editing <code>\/etc\/hostname<\/code> by hand; it updates the systemd hostname service, the running system, and the persistent file together.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo hostnamectl set-hostname NEW_HOSTNAME<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>NEW_HOSTNAME<\/code> with a value such as <code>web01<\/code> or <code>web01.example.com<\/code>. An FQDN is useful when the VPS has a public domain, but setting it here does not create a DNS record.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">AlmaLinux 8 also supports an optional pretty hostname for a label that may contain spaces:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo hostnamectl set-hostname \"NEW_PRETTY_NAME\" --pretty<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>NEW_PRETTY_NAME<\/code> with something like <code>Web server in Miami<\/code>. The commands normally return no text. Confirm both values immediately:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hostnamectl status --static\nhostnamectl status --pretty\ncat \/etc\/hostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output is similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>web01.example.com\nWeb server in Miami\nweb01.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/docs.redhat.com\/en\/documentation\/red_hat_enterprise_linux\/8\/html\/configuring_and_managing_networking\/assembly_changing-a-hostname_configuring-and-managing-networking\" target=\"_blank\" rel=\"noopener\">RHEL 8 hostname documentation<\/a> describes the static hostname as the value stored in <code>\/etc\/hostname<\/code>; <code>hostnamectl<\/code> also activates the new value through <code>systemd-hostnamed<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Make the name resolve locally<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The hostname can be set correctly and still fail lookups if the VPS has no DNS record yet, so add a local mapping for services that need to resolve the server&#8217;s own name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Find the source address used for the default IPv4 route:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ip -4 route get 1.1.1.1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Look for the <code>src<\/code> value, then open the hosts 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>localhost<\/code> and IPv6 lines. Add a line in this format, replacing every uppercase placeholder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SERVER_IP NEW_HOSTNAME NEW_SHORT_NAME<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example, an FQDN might use this entry:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>203.0.113.40 web01.example.com web01<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you chose only <code>web01<\/code>, use <code>SERVER_IP web01<\/code> instead. Save the file, then test the local resolver:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getent hosts NEW_HOSTNAME\nhostname --fqdn<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Successful output contains the server address and the chosen name:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>203.0.113.40  web01.example.com web01\nweb01.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The hosts file affects this server only. To make the name work from laptops, monitoring systems, or other VPSs, create an A record for IPv4 or an AAAA record for IPv6 at your DNS provider.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Change it with NetworkManager when needed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nmcli<\/code> is a useful alternative on AlmaLinux 8 because NetworkManager owns the system hostname on many installations and exposes a direct hostname setting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Display the current NetworkManager value and set the new one:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmcli general hostname\nsudo nmcli general hostname NEW_HOSTNAME\nnmcli general hostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The final command should print the new value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>web01.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also use the text interface if you prefer a menu over a command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y NetworkManager-tui\nsudo nmtui<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the menu, choose <strong>Set system hostname<\/strong>, enter the new name, select <strong>OK<\/strong>, and choose <strong>Quit<\/strong>. This changes the same static hostname managed by <code>hostnamectl<\/code>; it does not edit <code>\/etc\/hosts<\/code> or publish DNS, so complete Step 3 when local resolution is required.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Refresh shells and dependent services<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The kernel sees the new name immediately, but an existing SSH prompt and applications that read the hostname only at startup can retain the old value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check that the hostname service is active and that the persistent file is correct:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl is-active systemd-hostnamed\ncat \/etc\/hostname<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>active\nweb01.example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Reconnect over SSH to refresh your shell prompt. Restart only a service that is known to cache the hostname, using its real unit name:<\/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 an actual application service. Do not restart NetworkManager solely because the hostname changed, and do not reboot unless another maintenance task requires it.<\/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 these checks together to confirm the persistent name, optional description, fully qualified result, and resolver mapping:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hostnamectl status --static\nhostnamectl status --pretty\nhostname --fqdn\ngetent hosts NEW_HOSTNAME<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The static hostname and FQDN should show the new name. The pretty check is blank unless you set one, and <code>getent<\/code> should return the address from <code>\/etc\/hosts<\/code> or DNS. If the first and third checks agree and the resolver returns the expected address, the AlmaLinux 8 configuration is complete.<\/p>\n\n\n\n<aside class=\"vl-element vl-cta-banner\" aria-label=\"Set a clean server identity\">\n\t<div class=\"vl-cta-banner__content\">\n\t\t<p class=\"vl-cta-banner__eyebrow\">AlmaLinux VPS<\/p>\n\t\t<h3 class=\"vl-cta-banner__title\">Set a clean server identity<\/h3>\n\t\t<p class=\"vl-cta-banner__text\">Deploy an AlmaLinux VPS with root access for fast hostname and network setup.<\/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\">The old hostname returns after a reboot<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cloud-init, DHCP, or the VPS image&#8217;s provisioning settings may be applying a hostname during boot. Check whether cloud-init is installed and reporting a running configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rpm -q cloud-init\nsudo cloud-init status --long<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the package is installed and the provider permits local overrides, preserve the manual value for future boots:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo install -d -m 0755 \/etc\/cloud\/cloud.cfg.d\nprintf 'preserve_hostname: true\\n' | 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\">If the provider&#8217;s provisioning system still resets it, update the hostname in the VPS provisioning or control-panel settings too.<\/p>\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 value contains a space, underscore, or unsupported punctuation, or an FQDN label starts or ends with a hyphen. Use lowercase letters, digits, hyphens, and dots for the static name; put spaces in the optional <code>--pretty<\/code> value instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>hostname --fqdn<\/code> prints <code>localhost<\/code> or fails<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The static hostname exists, but local name resolution does not map it to an address. Add the server&#8217;s real IP, FQDN, and short alias to <code>\/etc\/hosts<\/code>, then rerun <code>getent hosts NEW_HOSTNAME<\/code>. If other machines need the name, add the corresponding public DNS record as well.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>nmtui: command not found<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The text interface is an optional package on minimal AlmaLinux 8 images. Install <code>NetworkManager-tui<\/code> with <code>dnf<\/code>, or skip the menu and use <code>hostnamectl<\/code>, which is the simpler method for a remote SSH session.<\/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>Create and test the public A or AAAA record if the hostname is an FQDN.<\/li>\n\n\n<li>Configure a matching reverse-DNS\/PTR record in the VPS control panel when mail or monitoring depends on reverse lookups.<\/li>\n\n\n<li>Update backup, monitoring, and configuration-management inventory if those systems identify the server by its old hostname.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Does changing the hostname require a reboot on AlmaLinux 8?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. <code>hostnamectl<\/code> changes the active hostname and writes the persistent value immediately. Reconnect your SSH session and restart only applications that read the hostname once during startup.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I choose a short hostname or an FQDN?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A short name is enough for a private, single-server setup. Choose an FQDN when the VPS participates in DNS, TLS, mail, monitoring, or a larger cluster, and make sure that name resolves locally and publicly where needed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Will this change update DNS or reverse DNS?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. The command changes the operating system&#8217;s local identity. Manage the forward record with your DNS provider and the PTR record through the system that controls your VPS address.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why is the pretty hostname different from the static hostname?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The static hostname is the machine name used by the operating system and commonly stored in <code>\/etc\/hostname<\/code>. The pretty hostname is an optional descriptive label for people, so it may contain spaces and is not a substitute for a DNS name.<\/p>\n\n\n\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Does changing the hostname require a reboot on AlmaLinux 8?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. `hostnamectl` changes the active hostname and writes the persistent value immediately. Reconnect your SSH session and restart only applications that read the hostname once during startup.\"}}, {\"@type\": \"Question\", \"name\": \"Should I choose a short hostname or an FQDN?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"A short name is enough for a private, single-server setup. Choose an FQDN when the VPS participates in DNS, TLS, mail, monitoring, or a larger cluster, and make sure that name resolves locally and publicly where needed.\"}}, {\"@type\": \"Question\", \"name\": \"Will this change update DNS or reverse DNS?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. The command changes the operating system's local identity. Manage the forward record with your DNS provider and the PTR record through the system that controls your VPS address.\"}}, {\"@type\": \"Question\", \"name\": \"Why is the pretty hostname different from the static hostname?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"The static hostname is the machine name used by the operating system and commonly stored in `\/etc\/hostname`. The pretty hostname is an optional descriptive label for people, so it may contain spaces and is not a substitute for a DNS name.\"}}]}<\/script>\n\n","protected":false},"excerpt":{"rendered":"Change hostname in AlmaLinux 8 with hostnamectl, fix local name resolution, keep cloud-init from overwriting it, and verify the result safely in minutes.","protected":false},"author":1,"featured_media":910,"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":[94,106,93],"class_list":["post-909","post","type-post","status-publish","format-standard","has-post-thumbnail","category-guides","category-vps-hosting","tag-almalinux-8","tag-hostname","tag-linux-vps","cs-entry"],"_links":{"self":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/909","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=909"}],"version-history":[{"count":1,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/909\/revisions"}],"predecessor-version":[{"id":3705,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/909\/revisions\/3705"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media\/910"}],"wp:attachment":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media?parent=909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/categories?post=909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/tags?post=909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}