{"id":1598,"date":"2018-10-25T01:58:58","date_gmt":"2018-10-25T01:58:58","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1598"},"modified":"2018-10-25T02:26:31","modified_gmt":"2018-10-25T02:26:31","slug":"how-to-change-the-hostname-of-your-linux-machine-without-needing-to-restart-the-ultimate-linux-newbie-guide","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/25\/how-to-change-the-hostname-of-your-linux-machine-without-needing-to-restart-the-ultimate-linux-newbie-guide\/","title":{"rendered":"How to change the hostname of your Linux machine without needing to restart \u2014 The Ultimate Linux Newbie Guide"},"content":{"rendered":"<h3>hostnamectl method<\/h3>\n<p>Since Ubuntu 16.04 (and most recent Linux distros) use Systemd you can simply use the hostnamectl command to change hostname. To see current setting, run your Terminal just type the following <a href=\"http:\/\/linuxnewbieguide.org\/overview-of-chapters\/more-advanced-guides\/command-line-interface\/\">command<\/a>:<\/p>\n<p>$ hostnamectl<br \/>\nSample output:<\/p>\n<table>\n<tbody>\n<tr>\n<td>Static hostname: lappy686<br \/>\nIcon name: computer-laptop<br \/>\nChassis: laptop<br \/>\nMachine ID: 52ff3d3eefa19d99891c3cf4b70a138b<br \/>\nBoot ID: fefe3aaf139855243a837001fedc7713<br \/>\nOperating System: Ubuntu 18.04<br \/>\nKernel: Linux 4.16.0-33-generic<br \/>\nArchitecture: x86-64<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To change hostname from lappy686 to ulng-laptop, enter:<br \/>\n$ hostnamectl set-hostname ulng-laptop<\/p>\n<p>Type hostnamectl again to see that the hostname has updated.<\/p>\n<h3>Classic Method<\/h3>\n<p>If you don\u2019t have such a new machine, then you can perform the following steps:<\/p>\n<p>Type the following commands:<br \/>\n$ sudo hostname new-hostname-here<\/p>\n<p>Next edit the \/etc\/hostname file and update hostname:<br \/>\n$ sudo nano \/etc\/hostname<\/p>\n<p>Finally, edit the \/etc\/hosts file and update the lines that contain your old hostname:<br \/>\n$ sudo nano \/etc\/hosts<\/p>\n<p>From:<br \/>\n127.0.1.1 old-host-name<\/p>\n<p>To:<br \/>\n127.0.1.1 new-hostname-here<\/p>\n<p>Save and close the file.<\/p>\n<p><a href=\"https:\/\/linuxnewbieguide.org\/how-to-change-hostname-without-a-restart\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>hostnamectl method Since Ubuntu 16.04 (and most recent Linux distros) use Systemd you can simply use the hostnamectl command to change hostname. To see current setting, run your Terminal just type the following command: $ hostnamectl Sample output: Static hostname: lappy686 Icon name: computer-laptop Chassis: laptop Machine ID: 52ff3d3eefa19d99891c3cf4b70a138b Boot ID: fefe3aaf139855243a837001fedc7713 Operating System: Ubuntu &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/25\/how-to-change-the-hostname-of-your-linux-machine-without-needing-to-restart-the-ultimate-linux-newbie-guide\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to change the hostname of your Linux machine without needing to restart \u2014 The Ultimate Linux Newbie Guide&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1598","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1598"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1598\/revisions"}],"predecessor-version":[{"id":1641,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1598\/revisions\/1641"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}