{"id":1301,"date":"2017-07-22T15:42:11","date_gmt":"2017-07-22T15:42:11","guid":{"rendered":"https:\/\/www.xsofthost.com\/help\/?p=1301"},"modified":"2021-03-16T00:25:32","modified_gmt":"2021-03-16T00:25:32","slug":"change-centos-hostname-server","status":"publish","type":"post","link":"https:\/\/www.xsofthost.com\/help\/change-centos-hostname-server\/","title":{"rendered":"How to change Server Hostname In Centos"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1301\" class=\"elementor elementor-1301\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-58be185 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"58be185\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-714158b\" data-id=\"714158b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-80bc215 elementor-widget elementor-widget-text-editor\" data-id=\"80bc215\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>We are going to learn here how to change server hostname .<\/p>\n<p>But first what is Server Hostname:<\/p>\n<p>Every server is started with the server\u2019s given name as the <b>hostname<\/b>. Sometimes when the server host some softwares, such as cPanel, that requires a valid Fully Qualified Domain Name (FQDN) for the hostname to be used during their licensing verification system. So its important to set the FQDN hostname for your server .<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-bb90afd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"bb90afd\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-51647bc\" data-id=\"51647bc\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9d069a0 elementor-widget elementor-widget-heading\" data-id=\"9d069a0\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Hostname Naming Rules<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-afd38b8 elementor-widget elementor-widget-text-editor\" data-id=\"afd38b8\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Hostname can be set to any name you like, but you should keep in mind the following rules:<\/p>\n<ul>\n<li>hostnames can contain letters (from a to z) and \/or digits (from 0 to 9).<\/li>\n<li><span style=\"background-color: transparent; color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight );\">Also it can contain only the hyphen character ( \u2013 ) as a special character and \/or\u00a0\u00a0dot special character ( . )\u00a0.<\/span><\/li>\n<li><span style=\"background-color: transparent; color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight );\">hostnames can contain a combination of all above rules but must start and end with a letter or a number , and letters are case-insensitive.<\/span><\/li>\n<li><span style=\"background-color: transparent; color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight );\">hostnames must contain between 2 and 63 characters long.<\/span><\/li>\n<li>hostnames should be descriptive (to ease identifying the computer purpose, location, geographical area, etc on the network).<\/li>\n<\/ul>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-20fa179 elementor-widget elementor-widget-heading\" data-id=\"20fa179\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">How to Change Server Hostname<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9b8645d elementor-widget elementor-widget-text-editor\" data-id=\"9b8645d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>To modify the hostname, we need to modify \/etc\/hosts file First you have to Login to your server using root username privileges and edit the file by one of your favorite editor <b>\/etc\/sysconfig\/network<\/b> by running the following command<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a77f181 elementor-widget elementor-widget-code-highlight\" data-id=\"a77f181\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-okaidia copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>vi \/etc\/sysconfig\/network\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b8aa65d elementor-widget elementor-widget-text-editor\" data-id=\"b8aa65d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\tthen you have to change HOSTNAME= value to your FQDN hostname for example:\n\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bd63676 elementor-widget elementor-widget-code-highlight\" data-id=\"bd63676\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>HOSTNAME=yourserver.mydomain.com\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-aedb4b9 elementor-widget elementor-widget-text-editor\" data-id=\"aedb4b9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\tNow you need to change the Hostname in the file hosts ,that file used for internal network mapping IPs by running the command\n\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-04a915a elementor-widget elementor-widget-code-highlight\" data-id=\"04a915a\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-okaidia copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>vi \/etc\/hosts<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7a708e4 elementor-widget elementor-widget-text-editor\" data-id=\"7a708e4\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The new values of the content file should be<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6d7386a elementor-widget elementor-widget-code-highlight\" data-id=\"6d7386a\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>127.0.0.1 localhost localhost.localdomain\n93.184.216.34 yourserver.mydomain.com       yourserver<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a0e9385 elementor-widget elementor-widget-text-editor\" data-id=\"a0e9385\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\tNow you can run the hostname command. This command change the hostname on the server that the command line remembers, <b>but it does not actively update all programs that are running under the old hostname.<\/b>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-986bfcd elementor-widget elementor-widget-code-highlight\" data-id=\"986bfcd\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-okaidia copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>hostname yourserver.mydomain.com\nhostname\nyourserver.mydomain.com<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2448fc8 elementor-widget elementor-widget-text-editor\" data-id=\"2448fc8\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\tAlso you need to restart networking on your server to check that changes will persist on restart.\n\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bdca304 elementor-widget elementor-widget-code-highlight\" data-id=\"bdca304\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-okaidia copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>\/etc\/init.d\/network restart<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>We are going to learn here how to change server hostname . But first what is Server Hostname: Every server is started with the server\u2019s given name as the hostname. Sometimes when the server host some softwares, such as cPanel, that requires a valid Fully Qualified Domain Name (FQDN) for the hostname to be used [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":859,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[181,178,42,50,149,74],"_links":{"self":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/1301"}],"collection":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/comments?post=1301"}],"version-history":[{"count":45,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/1301\/revisions"}],"predecessor-version":[{"id":2414,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/1301\/revisions\/2414"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/media\/859"}],"wp:attachment":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/media?parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/categories?post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/tags?post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}