• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Change Hostname on Debian 11

Written by Admin, Updated On January 19, 2023
debian, hostname
How to Change Hostname Debian 11

This tutorial outlines steps to change hostname on Debian 11 Bullseye. The hostname will set at the time of installation of Debian operating system. If you are creating a virtual machine, it will dynamically assign when instance created.

Prerequisites#

Make sure that you are logged in as a non-root user with sudo privileges.

Change Hostname on Debian 11

By assigning a hostname you can identifies a system on a network. You must make sure that there shouldn’t have same hostname on a same network. It is recommended to use a fully-qualified domain name (FQDN) as the system hostname.

Get Current Hostname#

At first, you need to check current hostname. To get the current hostname, run the below command:

hostnamectl
  Static hostname: local.tecnstuff.net
        Icon name: computer-vm
          Chassis: vm
       Machine ID: 287b816ad03c4f429f7bb49501983e1c
          Boot ID: 7fd5cca4dd5c41f6ac53214e11fa3f57
   Virtualization: oracle
 Operating System: Debian GNU/Linux 11 (bullseye)
           Kernel: Linux 5.19.0-5-amd64
     Architecture: x86-64

In above output you can see that the current hostname is local.tecnstuff.

Changing the Hostname using hostnamectl#

In Debian 11, there are multiple methods to change hostname. First one is change the hostname using hostnamectl command. Following is the basic syntax to change hostname:

sudo hostnamectl set-hostname NEW_HOST_NAME

You can run command as below to change hostname:

sudo hostnamectl set-hostname server.tecnstuff.net

We changed the hostname from local.tecnstuff to server.tecnstuff.net using hostnamectl command. Now the hostname is server.tecnstuff.net for server, you can check it again using hostnamectl command.

Change the Hostname by Edit /etc/hosts file#

Another method to change hostname is to edit /etc/hosts file manually. Open /etc/hosts file using your favorite text editor:

sudo nano /etc/hosts

Inside the file, change the hostname as per you choice at line that begins with 127.0.0.1

127.0.0.1 localhost

127.0.1.1 tecnstuff

Save and close file. For this method you need to restart your system.

Verify Hostname#

After changed hostname using second method, you can again check hostname using hostnamectl command and now it should give output with new hostname as below:

  Static hostname: server.tecnstuff.net
        Icon name: computer-vm
          Chassis: vm
       Machine ID: 287b816ad03c4f429f7bb49501983e1c
          Boot ID: 7fd5cca4dd5c41f6ac53214e11fa3f57
   Virtualization: oracle
 Operating System: Debian GNU/Linux 11 (bullseye)
           Kernel: Linux 5.19.0-5-amd64
     Architecture: x86-64

As you can see above the hostname is successfully changed from local.tecnstuff to server.tecnstuff.net .

Conclusion#

Finally, you learned how to change the hostname on Debian 11 bullseye system using different methods.

If you face any issues or have any suggestions you can leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Composer on Ubuntu 22.04
Next Article   How to Install R on Ubuntu 22.04

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install and Use Docker on Debian 11

    How to Install and Use Docker on Debian 11

    March 10, 2023
  • How to Install MariaDB on Debian 11 Bullseye

    How to Install MariaDB on Debian 11 Bullseye

    March 8, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook