{"id":17776,"date":"2022-06-14T19:36:24","date_gmt":"2022-06-14T19:36:24","guid":{"rendered":"https:\/\/linuxways.net\/?p=17776"},"modified":"2022-06-14T19:36:24","modified_gmt":"2022-06-14T19:36:24","slug":"how-to-change-hostname-in-debian-11","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/how-to-change-hostname-in-debian-11\/","title":{"rendered":"How to Change Hostname in Debian 11"},"content":{"rendered":"<p>A hostname is a name given to a computer that is connected to a network. It identifies your system on the network. The hostname in Debian is normally set during the OS installation, although you can change it later using several methods.<\/p>\n<p>We will discuss the different ways of changing the hostname on Debian 11 Bullseye Distribution in this article.<\/p>\n<h2><strong>How to change the hostname in Debian 11?<\/strong><\/h2>\n<p>You can change the hostname of your Debian system by using different ways that we have listed:<\/p>\n<h3>Change hostname using the hostname command<\/h3>\n<p>The easiest method to change the hostname of a Linux system is by using the <strong>\u2018hostname\u2019 <\/strong>command. However, it is important to note that this method will temporarily change the hostname. The hostname changes are set to default on the system reboot.<\/p>\n<p>To change or set the hostname in Debian 11, use the \u2018hostname\u2019 command in the following way:<\/p>\n<pre>$ sudo hostname newhost_name<\/pre>\n<p>For example, if you want to change the hostname \u2018Debian11-distro\u2019 then, replace the \u2018newhost_name\u2019 with your hostname \u2018Debian11-distro\u2019.<\/p>\n<pre>$ sudo hostname Debian11-distro<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"78\" class=\"wp-image-17777\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-1.png 730w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-1-300x32.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/p>\n<p>To view the updated hostname, use this command:<\/p>\n<pre>$ hostname<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"69\" class=\"wp-image-17778\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-2.png 723w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-2-300x29.png 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/p>\n<h3>Change hostname using hostnamectl command<\/h3>\n<p>If you want to change the hostname permanently, in this case, this method is the most commonly used method for permanently changing the hostname on all Linux distributions.<\/p>\n<p>The <strong>\u2018hostnamectl\u2019<\/strong> command permanently changes the hostname in Debian 11.<\/p>\n<pre>$ sudo hostnamectl set-hostname Debian11-distro<\/pre>\n<p>To view the updated hostname, restart the system and use this command on the<\/p>\n<p>Terminal:<\/p>\n<pre>$ hostnamectl<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"224\" class=\"wp-image-17779\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-3.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-3-300x92.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>If you want to display the hostname only, use the \u2018&#8211;static\u2019 flag with the hostnamectl command.<\/p>\n<pre>$ hostnamectl \u2013static<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"58\" class=\"wp-image-17780\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-4.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-4-300x24.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h3>Change hostname using the sysctl command<\/h3>\n<p>The <strong>\u2018sysctl\u2019 <\/strong>command also allows you to change the hostname in Debian11-PC.<\/p>\n<pre>$ sudo sysctl kernel.hostname=Debian11-PC<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"80\" class=\"wp-image-17781\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-5.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-5-300x33.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<p>Restart your system to view the changes.<\/p>\n<h3>Using the nmcli command<\/h3>\n<p>The <strong>nmcli <\/strong>(network manager command-line interface) tool helps you to control the NetworkManager. Using the nmcli tool, we can easily change the hostname. Simply just run the nmcli command in the following order:<\/p>\n<pre>$ sudo nmcli general hostname Debian11-PC<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"75\" class=\"wp-image-17782\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-6.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-6-300x31.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<h3>Change hostname in \/etc\/hostname file<\/h3>\n<p>You can modify the hostname in the <strong>\u2018\/etc\/hostname\u2019 <\/strong>file. Open the file in your favorite text editor:<\/p>\n<pre>$ sudo nano \/etc\/hostname<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"39\" class=\"wp-image-17783\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-7.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-7-300x16.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>Update the hostname by replacing the previous one in this file. Save all changes by pressing <strong>\u2018Ctrl+O\u2019 <\/strong>and<strong> \u2018Ctrl+x\u2019<\/strong> to exit from the window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"481\" class=\"wp-image-17784\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-8.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-8-300x198.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<h3>Using nmtui utility<\/h3>\n<p>The \u2018nmtui\u2019 command allows you to change the hostname in Debian 11. Execute the \u2018nmtui\u2019 command in the terminal and the following dialogue will pop up on the terminal screen. Use the arrows keys for navigation and select the option<strong> \u2018Set system hostname\u2019.<\/strong> Now, press<strong> \u2018Enter\u2019 <\/strong>from your keyboard.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"477\" class=\"wp-image-17785\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-9.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-9-300x197.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>A new dialogue will pop up in the window. Enter the hostname name and select <strong>&lt;OK&gt;<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"433\" class=\"wp-image-17786\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-10.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-10-300x179.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-10-501x300.png 501w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<p>After authentication, press \u2018Enter\u2019 for confirmation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"588\" class=\"wp-image-17787\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-11.png 799w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-11-300x221.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-11-768x565.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"473\" class=\"wp-image-17788\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-12.png 723w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-12-300x196.png 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/p>\n<p>Next, navigate into the \u2018Quit\u2019 option in the <strong>Network Manager TUI <\/strong>window and press \u2018Enter\u2019.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"479\" class=\"wp-image-17789\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-13.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/06\/word-image-17776-13-300x198.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<h3>Conclusion<\/h3>\n<p>We explained different methods in this article about how to change the hostname in Debian 11. You can choose any method from all approaches that suit your needs.<\/p>","protected":false},"excerpt":{"rendered":"<p>A hostname is a name given to a computer that is connected to a network. It identifies your system on the network. The hostname in Debian is normally&hellip;<\/p>","protected":false},"author":1,"featured_media":17791,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[521,1043],"class_list":["post-17776","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-11","tag-hostname"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/17776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=17776"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/17776\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/17791"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=17776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=17776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=17776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}