{"id":857,"date":"2023-05-13T04:56:33","date_gmt":"2023-05-13T04:56:33","guid":{"rendered":"https:\/\/www.dedicatedcore.com\/blog\/?p=857"},"modified":"2024-10-15T11:49:44","modified_gmt":"2024-10-15T11:49:44","slug":"set-change-hostname-centos-almalinux-rockylinux","status":"publish","type":"post","link":"https:\/\/www.dedicatedcore.com\/blog\/set-change-hostname-centos-almalinux-rockylinux\/","title":{"rendered":"How to Change Hostname in CentOS | AlmaLinux | RockyLinux"},"content":{"rendered":"<p>A hostname serves as more than just a name for your computer; it is crucial for system management and network identification. An essential skill for system administrators is the ability to configure or modify a hostname in AlmaLinux. whether you&#8217;re configuring a new server or need to update an old one. We&#8217;ll walk you through configuring your system&#8217;s hostname in this article to help you create a distinct identity in your network environment. For self-healing, <a href=\"https:\/\/www.dedicatedcore.com\/blog\/install-kubernetes-cluster-centos\/\" target=\"_blank\" rel=\"noopener\">auto detecting &amp; fixing issues<\/a> with scaling install Kubernetes Cluster on CentOS.<\/p>\n<p>Here are the commands and GUI instructions for changing and setting the new hostname on the server and desktop distributions of Rocky Linux 8, AlmaLinux 8, or CentOS. We give each machine in a local or private network a name called a hostname to readily identify or separate it from other machines connected to the same network.<\/p>\n<p><iframe loading=\"lazy\" title=\"How to Change Hostname in Linux - AlmaLinux, Redhat, Centos , Rocky Linux\" width=\"719\" height=\"404\" src=\"https:\/\/www.youtube.com\/embed\/YKWxbogBsb4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>Change the Hostname in AlmaLinux 8 or Rocky Linux<\/h2>\n<h3>Step 1: Verify your Current AlmaLinux or Rocky Hostname.<\/h3>\n<p>Let&#8217;s check the hostname of our system now so that we can later verify that we have correctly changed it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">hostname<\/pre>\n<p>The command above simply prints the name of your system as it is right now, but you may use the following to gain more details:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">hostnamectl<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-859\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname.png\" alt=\"command to check current hostname\" width=\"800\" height=\"368\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname-300x138.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname-150x69.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname-768x353.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname-100x46.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/check-current-rockylinux-almalinux-hostname-700x322.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h3>Step 2: A command to Momentarily Modify the Hostname<\/h3>\n<p>Those who want to temporarily change the hostname for the current session on their Almalinux or Rocky Linux systems. They can follow the instructions below. However, the set hostname will revert to the original one that was previously established for ongoing usage as soon as you restart your computer or log out.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo hostname new-one<\/pre>\n<p>In the command above, change &#8220;new-one&#8221; to the hostname you want to use with your Linux system.<\/p>\n<p>You can restart your session to see results right away on your terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">newgrp<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-861\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily.png\" alt=\"command to change hostname temporarily\" width=\"800\" height=\"236\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily-300x89.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily-150x44.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily-768x227.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily-100x30.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-hostname-temporarily-700x207.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h3>Step 3: Permanently change the Hostname without Rebooting<\/h3>\n<p>Now use the hostnamectl command to change the hostname permanently without restarting your Rocky or Almalinux 8 system. the one we initially used to verify the hostname&#8217;s specifics.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo hostnamectl set-hostname new-host<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">newgrp<\/pre>\n<p>In the command above, change &#8220;new-host&#8221; to the host you want to set.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-862\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux.png\" alt=\"set hostname on rockylinux or almalinux\" width=\"800\" height=\"369\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux-300x138.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux-150x69.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux-768x354.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux-100x46.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/set-hostname-rockylinux-almalinux-700x323.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h3>Step 4: Using the \/etc\/hostname file (necessitates a reboot)<\/h3>\n<p>However, you can also manually modify a configuration file that contains your existing system name to change and specify a new hostname.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nano \/etc\/hostname<\/pre>\n<p>Remove the existing hostname from the file and replace it with the new one you want to configure. Afterward, save the document by pressing Ctrl+O, Enter, and Ctrl+X.<\/p>\n<p>4. To change the hostname for Almalinux or Rocky Linux 8, use the GUI.<\/p>\n<p>A lot of users of these RHEL-based Rocky and AlmaLinux systems prefer the graphical user interface over the command line. Therefore, users can choose the graphical method to quickly change the hostname.<\/p>\n<ul>\n<li>Navigate to the Rocky\/Almalinux 8 system settings.<\/li>\n<li>Pick the menu item titled &#8220;About.&#8221;<\/li>\n<li>In the Device name box, click.<\/li>\n<li>Put the new hostname in here.<\/li>\n<li>Snap the Settings shut.<\/li>\n<\/ul>\n<h3>Final Thoughts on Changing Hostname in CentOS<\/h3>\n<p>Setting or updating a hostname is a simple but crucial system administration activity in AlmaLinux. It facilitates network connectivity while also making system administration and troubleshooting simpler. By following the instructions, you have learned the knowledge necessary to competently maintain your system&#8217;s hostname and make sure that it appropriately identifies your server in your network.<\/p>\n<p>Your AlmaLinux-based infrastructure can function more effectively and be better organized with this tiny but important improvement. This tutorial described many alternatives for changing the hostname on RHEL or CentOS 8. Change the hostname on your CentOS 8 machine easily by selecting the preferred system name.<\/p>\n<h4>Frequently Asked Questions (FAQ)<\/h4>\n<p><strong>1. What is a Hostname in CentOS?<\/strong><\/p>\n<p>A hostname is a label assigned to a device in a network. It assists in determining the system uniquely on a network and can be used to decide machine names to IP addresses.<\/p>\n<p><strong>2. Why would I need to change the Hostname in CentOS?<\/strong><\/p>\n<p>To identify your server easily or to reflect the purpose of it one needs to change the Hostname in CentOS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A hostname serves as more than just a name for your computer; it is crucial for system management and network identification. An essential skill for&#8230;<\/p>\n","protected":false},"author":1,"featured_media":909,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/857"}],"collection":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/comments?post=857"}],"version-history":[{"count":11,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/857\/revisions"}],"predecessor-version":[{"id":2458,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/857\/revisions\/2458"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/media\/909"}],"wp:attachment":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/media?parent=857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/categories?post=857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/tags?post=857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}