{"id":3405,"date":"2024-12-12T05:31:58","date_gmt":"2024-12-12T05:31:58","guid":{"rendered":"https:\/\/platinumsupport.in\/blog\/?p=3405"},"modified":"2024-12-12T05:45:55","modified_gmt":"2024-12-12T05:45:55","slug":"how-to-setup-hostname-on-linux","status":"publish","type":"post","link":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/","title":{"rendered":"How to Set Up a Hostname via Command Line on Linux"},"content":{"rendered":"<article>\n<header><span style=\"font-size: revert; background-color: transparent; color: var(--theme-text-color); font-family: var(--theme-font-family); font-style: var(--theme-font-style, inherit); font-weight: var(--theme-font-weight); letter-spacing: var(--theme-letter-spacing); text-transform: var(--theme-text-transform);\">Below are the steps for both temporary and permanent changes, suitable for various Linux distributions.<\/span><\/p>\n<\/header>\n<section>\n<h2>1. Temporary Hostname Change (Resets on Reboot)<\/h2>\n<p>To temporarily change the hostname, use the <code>hostname<\/code> command. Note that this change will not persist after a reboot.<\/p>\n<pre><code>sudo hostname NEW_HOSTNAME<\/code><\/pre>\n<p>Replace <code>NEW_HOSTNAME<\/code> with your desired hostname.<\/p>\n<\/section>\n<section>\n<h2>2. Permanent Hostname Change<\/h2>\n<p>To make the hostname change persistent across reboots, follow these steps:<\/p>\n<h3>a. For Modern Linux Systems Using <code>hostnamectl<\/code><\/h3>\n<p>Most modern Linux distributions use <code>systemd<\/code>. Use the following command:<\/p>\n<pre><code>sudo hostnamectl set-hostname NEW_HOSTNAME<\/code><\/pre>\n<p>This will update the hostname permanently.<\/p>\n<h3>b. For Older Linux Systems<\/h3>\n<ol>\n<li>Edit the <code>\/etc\/hostname<\/code> file:\n<pre><code>sudo nano \/etc\/hostname<\/code><\/pre>\n<p>Replace the existing hostname with <code>NEW_HOSTNAME<\/code> and save the file.<\/li>\n<li>Update the <code>\/etc\/hosts<\/code> file:\n<pre><code>sudo nano \/etc\/hosts<\/code><\/pre>\n<p>Find the line starting with <code>127.0.0.1<\/code> and ensure it maps to the new hostname:<\/p>\n<pre><code>127.0.0.1   NEW_HOSTNAME<\/code><\/pre>\n<\/li>\n<li>Apply the changes:\n<pre><code>sudo systemctl restart systemd-hostnamed<\/code><\/pre>\n<p>Alternatively, reboot your system:<\/p>\n<pre><code>sudo reboot<\/code><\/pre>\n<\/li>\n<\/ol>\n<\/section>\n<section>\n<h2>3. Verify the Hostname<\/h2>\n<p>After making the changes, you can verify the hostname using one of the following commands:<\/p>\n<pre><code>hostname<\/code><\/pre>\n<p>Or:<\/p>\n<pre><code>hostnamectl<\/code><\/pre>\n<p>Both commands will display the current hostname.<\/p>\n<\/section>\n<footer>By following these steps, you can easily set up or change the hostname on your Linux system, whether temporarily or permanently.<\/p>\n<\/footer>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>Below are the steps for both temporary and permanent changes, suitable for various Linux distributions. 1. Temporary Hostname Change (Resets on Reboot) To temporarily change the hostname, use the hostname command. Note that this change will not persist after a reboot. sudo hostname NEW_HOSTNAME Replace NEW_HOSTNAME with your desired hostname. 2. Permanent Hostname Change To [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,44],"tags":[50,56,55,51,54,57,52,49,53],"class_list":["post-3405","post","type-post","status-publish","format-standard","hentry","category-cpanel-whm-technical-support-solutions","category-linux","tag-change-hostname-linux","tag-edit-hostname-linux","tag-hostnamectl-linux","tag-linux-hostname-command","tag-linux-hostname-setup","tag-linux-system-configuration","tag-permanent-hostname-change-linux","tag-set-up-hostname-in-linux","tag-temporary-hostname-change-linux"],"blocksy_meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.13 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Set Up or Change Hostname in Linux: Step-by-Step Guide<\/title>\n<meta name=\"description\" content=\"Learn how to set up or change the hostname on Linux via the command line. Step-by-step instructions for both temporary and permanent hostname changes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up a Hostname via Command Line on Linux\" \/>\n<meta property=\"og:description\" content=\"Learn how to set up or change the hostname on Linux via the command line. Step-by-step instructions for both temporary and permanent hostname changes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/platinumsupport.in\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-12T05:31:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-12T05:45:55+00:00\" \/>\n<meta name=\"author\" content=\"Anand\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anand\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\"},\"author\":{\"name\":\"Anand\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/#\/schema\/person\/aa475c6a968475a732f330a12ff18ede\"},\"headline\":\"How to Set Up a Hostname via Command Line on Linux\",\"datePublished\":\"2024-12-12T05:31:58+00:00\",\"dateModified\":\"2024-12-12T05:45:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\"},\"wordCount\":177,\"publisher\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/#organization\"},\"keywords\":[\"change hostname Linux\",\"edit hostname Linux\",\"hostnamectl Linux\",\"Linux hostname command\",\"Linux hostname setup\",\"Linux system configuration\",\"permanent hostname change Linux\",\"Set up hostname in Linux\",\"temporary hostname change Linux\"],\"articleSection\":[\"cPanel\/WHM\",\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\",\"url\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\",\"name\":\"How to Set Up or Change Hostname in Linux: Step-by-Step Guide\",\"isPartOf\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/#website\"},\"datePublished\":\"2024-12-12T05:31:58+00:00\",\"dateModified\":\"2024-12-12T05:45:55+00:00\",\"description\":\"Learn how to set up or change the hostname on Linux via the command line. Step-by-step instructions for both temporary and permanent hostname changes.\",\"breadcrumb\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/platinumsupport.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Up a Hostname via Command Line on Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/#website\",\"url\":\"https:\/\/platinumsupport.in\/blog\/\",\"name\":\"PlatinumSupport.in\",\"description\":\"Discover Success through Expert Guidance: Dive into the PlatinumSupport Blog for Solutions and Empowerment!\",\"publisher\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/platinumsupport.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/#organization\",\"name\":\"Tech Savy Systems\",\"url\":\"https:\/\/platinumsupport.in\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/platinumsupport.in\/blog\/wp-content\/uploads\/2024\/02\/psm-blog.png\",\"contentUrl\":\"https:\/\/platinumsupport.in\/blog\/wp-content\/uploads\/2024\/02\/psm-blog.png\",\"width\":250,\"height\":75,\"caption\":\"Tech Savy Systems\"},\"image\":{\"@id\":\"https:\/\/platinumsupport.in\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/platinumsupport.in\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/#\/schema\/person\/aa475c6a968475a732f330a12ff18ede\",\"name\":\"Anand\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/platinumsupport.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/610c86cd51134253c03e1441f07cd9c4e75bdbf5a06560ddc04e568bd85a89e5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/610c86cd51134253c03e1441f07cd9c4e75bdbf5a06560ddc04e568bd85a89e5?s=96&d=mm&r=g\",\"caption\":\"Anand\"},\"description\":\"I have been working in the web hosting support industry for over 15 years as a level 3 administrator, and I am proud to hold RED HAT certification. My expertise lies in providing support for Dedicated Servers, Cloud Servers, and VPS running various Linux operating systems such as CentOS, AlmaLinux, CloudLinux, and Ubuntu. Additionally, I am proficient in working with popular control panels like CPanel, Plesk, CWP, AApanel etc.\",\"sameAs\":[\"https:\/\/platinumsupport.in\/blog\"],\"honorificPrefix\":\"Mr\",\"honorificSuffix\":\"Er\",\"birthDate\":\"1980-11-11\",\"gender\":\"male\",\"knowsAbout\":[\"WebHosting Technical Support\"],\"knowsLanguage\":[\"English\",\"Hindi\",\"Marathi\"],\"jobTitle\":\"Level3 System Administrator\",\"worksFor\":\"PlatinumSupport.ni\",\"url\":\"https:\/\/platinumsupport.in\/blog\/author\/anand-v\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Set Up or Change Hostname in Linux: Step-by-Step Guide","description":"Learn how to set up or change the hostname on Linux via the command line. Step-by-step instructions for both temporary and permanent hostname changes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up a Hostname via Command Line on Linux","og_description":"Learn how to set up or change the hostname on Linux via the command line. Step-by-step instructions for both temporary and permanent hostname changes.","og_url":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/","og_site_name":"Knowledge Base","article_publisher":"https:\/\/facebook.com\/platinumsupport.in","article_published_time":"2024-12-12T05:31:58+00:00","article_modified_time":"2024-12-12T05:45:55+00:00","author":"Anand","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Anand","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/#article","isPartOf":{"@id":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/"},"author":{"name":"Anand","@id":"https:\/\/platinumsupport.in\/blog\/#\/schema\/person\/aa475c6a968475a732f330a12ff18ede"},"headline":"How to Set Up a Hostname via Command Line on Linux","datePublished":"2024-12-12T05:31:58+00:00","dateModified":"2024-12-12T05:45:55+00:00","mainEntityOfPage":{"@id":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/"},"wordCount":177,"publisher":{"@id":"https:\/\/platinumsupport.in\/blog\/#organization"},"keywords":["change hostname Linux","edit hostname Linux","hostnamectl Linux","Linux hostname command","Linux hostname setup","Linux system configuration","permanent hostname change Linux","Set up hostname in Linux","temporary hostname change Linux"],"articleSection":["cPanel\/WHM","Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/","url":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/","name":"How to Set Up or Change Hostname in Linux: Step-by-Step Guide","isPartOf":{"@id":"https:\/\/platinumsupport.in\/blog\/#website"},"datePublished":"2024-12-12T05:31:58+00:00","dateModified":"2024-12-12T05:45:55+00:00","description":"Learn how to set up or change the hostname on Linux via the command line. Step-by-step instructions for both temporary and permanent hostname changes.","breadcrumb":{"@id":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/platinumsupport.in\/blog\/how-to-setup-hostname-on-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/platinumsupport.in\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Set Up a Hostname via Command Line on Linux"}]},{"@type":"WebSite","@id":"https:\/\/platinumsupport.in\/blog\/#website","url":"https:\/\/platinumsupport.in\/blog\/","name":"PlatinumSupport.in","description":"Discover Success through Expert Guidance: Dive into the PlatinumSupport Blog for Solutions and Empowerment!","publisher":{"@id":"https:\/\/platinumsupport.in\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/platinumsupport.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/platinumsupport.in\/blog\/#organization","name":"Tech Savy Systems","url":"https:\/\/platinumsupport.in\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/platinumsupport.in\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/platinumsupport.in\/blog\/wp-content\/uploads\/2024\/02\/psm-blog.png","contentUrl":"https:\/\/platinumsupport.in\/blog\/wp-content\/uploads\/2024\/02\/psm-blog.png","width":250,"height":75,"caption":"Tech Savy Systems"},"image":{"@id":"https:\/\/platinumsupport.in\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/platinumsupport.in"]},{"@type":"Person","@id":"https:\/\/platinumsupport.in\/blog\/#\/schema\/person\/aa475c6a968475a732f330a12ff18ede","name":"Anand","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/platinumsupport.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/610c86cd51134253c03e1441f07cd9c4e75bdbf5a06560ddc04e568bd85a89e5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/610c86cd51134253c03e1441f07cd9c4e75bdbf5a06560ddc04e568bd85a89e5?s=96&d=mm&r=g","caption":"Anand"},"description":"I have been working in the web hosting support industry for over 15 years as a level 3 administrator, and I am proud to hold RED HAT certification. My expertise lies in providing support for Dedicated Servers, Cloud Servers, and VPS running various Linux operating systems such as CentOS, AlmaLinux, CloudLinux, and Ubuntu. Additionally, I am proficient in working with popular control panels like CPanel, Plesk, CWP, AApanel etc.","sameAs":["https:\/\/platinumsupport.in\/blog"],"honorificPrefix":"Mr","honorificSuffix":"Er","birthDate":"1980-11-11","gender":"male","knowsAbout":["WebHosting Technical Support"],"knowsLanguage":["English","Hindi","Marathi"],"jobTitle":"Level3 System Administrator","worksFor":"PlatinumSupport.ni","url":"https:\/\/platinumsupport.in\/blog\/author\/anand-v\/"}]}},"_links":{"self":[{"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/posts\/3405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/comments?post=3405"}],"version-history":[{"count":4,"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/posts\/3405\/revisions"}],"predecessor-version":[{"id":3413,"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/posts\/3405\/revisions\/3413"}],"wp:attachment":[{"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/media?parent=3405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/categories?post=3405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/platinumsupport.in\/blog\/wp-json\/wp\/v2\/tags?post=3405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}