{"id":43225,"date":"2022-10-21T02:42:35","date_gmt":"2022-10-21T02:42:35","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=43225"},"modified":"2024-05-04T12:58:56","modified_gmt":"2024-05-04T12:58:56","slug":"change-computer-name-ubuntu-2210","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2022\/10\/change-computer-name-ubuntu-2210\/","title":{"rendered":"How to Change Computer Name (hostname) in Ubuntu 24.04 without Restart"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-38307\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ubuntu2204-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This simple tutorial shows how to change the computer name (aka hostname) in your Ubuntu (Ubuntu 24.04 Noble Numbat updated) without a system restart.<\/p>\n<p>The methods here are universal ways that works in not only default Ubuntu release but also its flavors (e.g., KUbuntu, XUbuntu), and even other Linux.<\/p>\n<p><b>NOTE: A hostname can be a single word or phrase, including letters, number, periods, or hyphen with 253 characters length limit, with NO space.<\/b><\/p>\n<h4>Change Computer Name for Temporary Use<\/h4>\n<p>If possible to change the name for temporary use. So, the new name will work until you restart the system.<\/p>\n<ul>\n<li>To do so, simply open terminal or connect to command console and run command:\n<pre>sudo hostname NEW_NAME_HERE<\/pre>\n<\/li>\n<\/ul>\n<p>Replace &#8216;NEW_NAME_HERE&#8217; and type user password (no asterisk feedback) to authenticate. And, you may need to restart terminal or console to see effect.<\/p>\n<h4>Change Computer Name by Editing Config file<\/h4>\n<p>The classic way to permanently change your system hostname is just edit the configuration file!<\/p>\n<p>So, here I&#8217;m going to use the universal nano command line text editor to open the configuration file.<\/p>\n<ul>\n<li>To do so, open terminal and run command:\n<pre>sudo nano \/etc\/hostname<\/pre>\n<\/li>\n<\/ul>\n<p>When file opens in terminal, delete the old name and type a new one. Finally, press <b>Ctrl+X<\/b>, type <b>y<\/b> and hit Enter to save change.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/config-etchostname.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43226\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/config-etchostname-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/config-etchostname-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/config-etchostname-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/config-etchostname-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/10\/config-etchostname.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>This method however need a system restart if you&#8217;re running with default Wayland session. If you switched back Xorg session, run the command below to make it work without restart.<\/p>\n<pre>sudo systemctl restart systemd-logind.service<\/pre>\n<h4>Use &#8216;hostnamectl&#8217; to change computer name<\/h4>\n<p><b>The <code>hostnamectl<\/code> command is a good choice today to permanently change your computer name without system start.<\/b><\/p>\n<ul>\n<li>As easy as the first method, just run command in command\/console:\n<pre>hostnamectl hostname NEW_NAME_HERE<\/pre>\n<\/li>\n<\/ul>\n<p>The change takes effect immediately, though you may need to restart terminal window.<\/p>\n<h4>Use new name in &#8216;\/etc\/hosts&#8217;<\/h4>\n<p>To avoid network issues, it&#8217;s HIGHLY recommend to also edit &#8216;\/etc\/hosts&#8217; and replace all old names with new ones.<\/p>\n<ul>\n<li>Open terminal and run command to edit the file:\n<pre>sudo nano \/etc\/hosts<\/pre>\n<\/li>\n<\/ul>\n<p>When file opens in terminal, delete all the old hostname and insert the new name you set. Also, press <b>Ctrl+X<\/b>, type <b>y<\/b> and hit Enter to save change.<\/p>","protected":false},"excerpt":{"rendered":"<p>This simple tutorial shows how to change the computer name (aka hostname) in your Ubuntu (Ubuntu 24.04 Noble Numbat updated) without a system restart. The methods here are universal ways that works in not only default Ubuntu release but also its flavors (e.g., KUbuntu, XUbuntu), and even other Linux. NOTE: A hostname can be a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38307,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[733],"class_list":["post-43225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-computer-name"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=43225"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43225\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/38307"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=43225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=43225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=43225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}