{"id":2080,"date":"2017-09-24T20:47:10","date_gmt":"2017-09-24T15:17:10","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=2080"},"modified":"2026-09-09T10:43:11","modified_gmt":"2026-09-09T05:13:11","slug":"set-permanent-static-hostname-centos7-minimal-server","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/set-permanent-static-hostname-centos7-minimal-server\/","title":{"rendered":"How to set Permanent or Static hostname for CentOs7 Minimal Server."},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A hostname is a unique name assigned to a server or computer that helps identify it on a network. In CentOS 7, you can temporarily change the hostname using the <code>hostname<\/code> command, but the change will be lost after a reboot. To ensure the hostname remains unchanged even after restarting the server, you must configure a permanent (static) hostname.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to set a permanent hostname on a CentOS 7 Minimal Server, whether it is installed on a physical machine, VPS, or virtual machine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding, ensure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A CentOS 7 Minimal Server installed<\/li>\n\n\n\n<li>Root or sudo access to the server<\/li>\n\n\n\n<li>A desired hostname (for example: <code>abc.abc.com<\/code>)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Change Hostname Temporarily<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can change the hostname temporarily using the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostname abc.abc.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the current hostname:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostnamectl<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Sample Output<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Static hostname: localhost.localdomain\nTransient hostname: abc.abc.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>Transient hostname<\/strong> reflects the temporary change. However, after a server reboot, the hostname will revert to its previous value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Set a Permanent Hostname in CentOS 7<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To configure a hostname that persists across reboots, use the <code>hostnamectl<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostnamectl set-hostname abc.abc.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the change:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostnamectl<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Sample Output<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Static hostname: abc.abc.com\nIcon name: computer-vm\nChassis: vm\nMachine ID: 31ff204cc76641e99460750cef4d0e0e\nBoot ID: 9992b7511b4942c29ea48a0aada0294c\nVirtualization: vmware\nOperating System: CentOS Linux 7 (Core)\nKernel: Linux 3.10.0-514.el7.x86_64\nArchitecture: x86-64<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The hostname is now stored as the <strong>Static hostname<\/strong> and will remain unchanged after system reboots.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify Hostname Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can confirm the hostname at any time using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostnamectl status<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostname<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both commands should display the newly configured hostname.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Setting a permanent hostname in CentOS 7 is a simple but important system administration task. While the <code>hostname<\/code> command only changes the hostname temporarily, the <code>hostnamectl set-hostname<\/code> command ensures the hostname persists after reboots. Using a properly configured hostname improves server identification, network management, monitoring, and troubleshooting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions (FAQ)<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">1. What is the difference between a static hostname and a transient hostname?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>static hostname<\/strong> is permanently stored on the system and survives reboots. A <strong>transient hostname<\/strong> is temporary and may be assigned by DHCP or changed manually until the system restarts.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Do I need to reboot the server after changing the hostname?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">No. The hostname change takes effect immediately when using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostnamectl set-hostname &lt;hostname><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3. How can I check the current hostname on CentOS 7?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Use either of the following commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostname<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">hostnamectl<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both commands display the current hostname configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-centos-7-vmware-fusion-mac-os\/\">How to Install CentOS 7 on VMware Fusion for Mac OS<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/check-ip-address-centos-7-minimal-server-ifconfig-not-working\/\">How to Check IP Address on CentOS 7 Minimal Server When ifconfig Is Not Available<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/find-default-gateway-centos7-minimal-server\/\">How to Find the Default Gateway in CentOS 7 Minimal Server<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to our experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team&nbsp;<a href=\"https:\/\/pheonixsolutions.com\/contact\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction A hostname is a unique name assigned to a server or computer that helps identify it on a network. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-2080","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-xy","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2080"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2080\/revisions"}],"predecessor-version":[{"id":11567,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2080\/revisions\/11567"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}