How to change hostname on Debian 10 Linux nixCraft Updated Tutorials/Posts

See all Debian/Ubuntu Linux related FAQ

How do I change the hostname of a Debian Linux 10 “Buster” operating system permanently using the command line tools?

You can use the hostnamectl command or hostname command to display or set the Debian Linux system’s host name. In this tutorial, you will learn how to change your hostname on Debian Linux.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Debian Linux
Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
  • Join Patreon ➔

    127.0.0.1	localhost
    192.168.2.100 deb10.cyberciti.biz # The following lines are desirable for IPv6 capable hosts
    ::1 localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters

    Save and close the file.

    Verify the change

    How do you know that hostname was successfully changed? You use the same command without any arguments. In other words, type the following command:
    hostnamectl
    Change hostname on Debian 10 Linux Buster

    Change hostname on Debian 10 Linux Buster

    Set a particular pretty host name

    The syntax is:
    hostnamectl set-hostname "Vivek's Thinkpad" --pretty

    Changing Debian host names remotely using ssh

    From your Linux desktop, run:
    hostnamectl set-hostname -H [username]@hostname
    hostnamectl set-hostname {new_name_here} -H root@192.168.2.10
    hostnamectl set-hostname www42.nixcraft.com -H root@192.168.2.10

    The hostnamectl tool will use SSH to connect to the remote system. One can see help page by typing:
    hostnamectl --help
    Sample help page:

    hostnamectl [OPTIONS...] COMMAND ...
     
    Query or change system hostname.
      -h --help Show this help --version Show package version --no-ask-password Do not prompt for password -H --host=[USER@]HOST Operate on remote host -M --machine=CONTAINER Operate on local container --transient Only set transient hostname --static Only set static hostname --pretty Only set pretty hostname
     
    Commands: status Show current hostname settings set-hostname NAME Set system hostname set-icon-name NAME Set icon name for host set-chassis NAME Set chassis type for host set-deployment NAME Set deployment environment for host set-location NAME Set location for host
     
    See the hostnamectl(1) man page for details.

    Conclusion

    On Debian Linux hostnamectl command used to query and change the system hostname and related settings. For more information see the man page here or read it locally using the man command:
    man hostnamectl

    ADVERTISEMENT

    Posted by Contributor