{"id":5520,"date":"2023-11-24T11:28:45","date_gmt":"2023-11-24T11:28:45","guid":{"rendered":"https:\/\/natsav.com\/blog\/?p=5520"},"modified":"2024-02-02T12:18:11","modified_gmt":"2024-02-02T12:18:11","slug":"change-hostname-in-centos-7","status":"publish","type":"post","link":"https:\/\/natsav.com\/blog\/change-hostname-in-centos-7\/","title":{"rendered":"How To Change The Hostname in Centos 7."},"content":{"rendered":"<p><span style=\"text-decoration: underline; color: #000000;\"><strong>Step 1<\/strong><\/span>: Open a terminal window. You can do this by pressing <code>'Ctrl + Alt + T'<\/code> or by accessing the terminal from the Applications menu.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong><span style=\"color: #000000; text-decoration: underline;\">Step 2<\/span><\/strong><\/span><strong>:<\/strong> To check the current hostname, you can use the following command:-<br \/>\n# [ hostname ]<\/p>\n<p><span style=\"text-decoration: underline;\"><strong><span style=\"color: #000000; text-decoration: underline;\">Step 3<\/span><\/strong><\/span><strong>:<\/strong> To change the <strong><a href=\"https:\/\/natsav.com\/blog\/install-php-7-4-on-centos-7\/\">hostname<\/a><\/strong> temporarily (until the next reboot), you can use the <code>'hostname'<\/code> command with the new hostname. For example:-<br \/>\n# [ sudo hostname your-new-hostname ]<br \/>\n<strong>Note:<\/strong> Replace &#8220;your-new-hostname&#8221; with the desired hostname.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong><span style=\"color: #000000; text-decoration: underline;\">Step 4<\/span><\/strong><\/span><strong>: <\/strong>To make the hostname change permanent, you need to update the <code>'\/etc\/hostname'<\/code> file with the new hostname. Use a text editor to open the file. You can use a command-line editor like <code>nano<\/code> or <code>vi<\/code>. Here&#8217;s an example using <code>'nano'<\/code>:-<br \/>\n# [ sudo nano \/etc\/hostname ]<br \/>\n<strong>Note:<\/strong> Replace the existing hostname with your new hostname and save the file.<\/p>\n<p><span style=\"text-decoration: underline; color: #000000;\"><strong>Step 5<\/strong><\/span>: Additionally, you need to update the <code>'\/etc\/hosts'<\/code> file with the new hostname. Open the file using a text editor:-<br \/>\n# [ sudo nano \/etc\/hosts ]<br \/>\nFind the line with the old hostname and update it with the new one and Save the file.<\/p>\n<p><b><u>Step 6<\/u>: <\/b>After making these changes, you should restart the system or restart the <code>'systemd-hostnamed'<\/code> service for the changes to take effect:-<br \/>\n# [ sudo systemctl restart systemd-hostnamed ]<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Step 7<\/strong><\/span><strong>:<\/strong> Alternatively, you can reboot the system:-<br \/>\n# [ sudo reboot ]<br \/>\nAfter the reboot, your CentOS 7 system should have the new hostname. You can verify this by running the <code>'hostname'<\/code> command again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Open a terminal window. You can do this by pressing &#8216;Ctrl + Alt + T&#8217; or by accessing the terminal from the Applications menu. Step 2: To check the current hostname, you can use the following command:- # [ hostname ] Step 3: To change the hostname temporarily (until the next reboot), you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5521,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[256],"tags":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/natsav.com\/blog\/wp-content\/uploads\/2023\/11\/Hostname-e1700825320621.jpg?fit=736%2C302&ssl=1","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5520"}],"collection":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/comments?post=5520"}],"version-history":[{"count":2,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5520\/revisions"}],"predecessor-version":[{"id":5856,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5520\/revisions\/5856"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media\/5521"}],"wp:attachment":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media?parent=5520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/categories?post=5520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/tags?post=5520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}