Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Tutorials»How to Change Hostname (Computer Name) on Ubuntu & Debian

    How to Change Hostname (Computer Name) on Ubuntu & Debian

    RahulBy RahulMarch 15, 20182 Mins ReadUpdated:March 16, 2018

    Brief: This tutorial will show you to how to find current hostname of the system. Also, how can you change the hostname of your Ubuntu, Debian and LinuxMint systems?

    Change Hostname using Hostnamectl

    The latest operating systems (Eg: Ubuntu 18.04, 16.04, Debian 9/8) running with systemd uses hostnamectl command to manage computer hostname.

    You can change the hostname of Linux system using the following command. For example, you need to set computer hostname to webhost1.

    hostnamectl set-hostname webhost1
    

    This will update /etc/hostname file on your system and load in the current environment. But you still need hostname binding with localhost IP.

    Edit /etc/hosts file to bind new hostname with localhost IP address.

    127.0.1.1  webhost1
    

    Now, Execute the below command to find current hostname set for your system.

    hostnamectl 
    
       Static hostname: webhost1
             Icon name: computer-vm
               Chassis: vm
            Machine ID: 844c6ba3394d4646bd27ba204be67f27
               Boot ID: 5030cf55956a4c32ad3d6b7f391a3c77
        Virtualization: xen
      Operating System: Ubuntu 16.04.3 LTS
                Kernel: Linux 4.4.0-1049-aws
          Architecture: x86-64
    

    Change Hostname Manually

    You also use older way to change the hostname of the system manually by editing configuration files directly. To change hostname first edit /etc/hostname file and write your hostname there.

    /etc/hostname:

    webhost1
    

    After editing the file, you can also set the hostname for the current session to avoid system reboot.

    hostname webhost1
    

    After that edit /etc/hosts file to bind new hostname with localhost IP address.

    127.0.1.1  webhost1
    
    hostname hostnamectl
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Install PHP (7.4, 7.3 & 5.6) on Debian 9 Stretch
    Next Article How to Change Hostname (Computer Name) on Fedora & CentOS

    Related Posts

    How to Setup Squid Proxy Server on Ubuntu and Debian

    Updated:June 17, 20225 Mins Read

    How to Delete a Let’s Encrypt Certificate using Certbot

    Updated:June 3, 20222 Mins Read

    How to Install Latest Git on Ubuntu 22.04

    Updated:May 31, 20222 Mins Read

    How To Install LibreOffice on Ubuntu 22.04

    Updated:May 23, 20222 Mins Read

    (Resolved) userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

    Updated:May 10, 20221 Min Read

    How to Install Apache ActiveMQ on Ubuntu 22.04

    3 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    • How to Install Angular CLI on Ubuntu 22.04
    • How to Install Composer on Ubuntu 22.04
    • How to Create DMARC Record For Your Domain
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.