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 Fedora & CentOS

    How to Change Hostname (Computer Name) on Fedora & CentOS

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

    Brief: This article describes you to how to find current hostname of the system. Also, how can you change the hostname of your Redhat based systems?

    Change Hostname using Hostnamectl

    The latest Fedora and CentOS operating systems 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 workstation1.

    sudo hostnamectl set-hostname workstation1
    

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

    Also edit /etc/hosts file and add new hostname with localhost IP address like:
    127.0.1.1 workstation1.

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

    hostnamectl 
    
       Static hostname: workstation1
             Icon name: computer-vm
               Chassis: vm
            Machine ID: b669a2e70002461cac387ba87397c78b
               Boot ID: a0b60ab33f8e43aa9d04b9950f91ab6c
        Virtualization: oracle
      Operating System: Fedora 26 (Workstation Edition)
           CPE OS Name: cpe:/o:fedoraproject:fedora:26
                Kernel: Linux 4.13.5-200.fc26.x86_64
          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:

    workstation1
    

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

    hostname workstation1
    

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

    127.0.1.1  workstation1
    
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Change Hostname (Computer Name) on Ubuntu & Debian
    Next Article How to Compile and Install Redis Latest Version on a Linux VPS

    Related Posts

    What is the /etc/aliases file

    2 Mins Read

    What is the /etc/nsswitch.conf file in Linux

    2 Mins Read

    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

    Leave A Reply Cancel Reply

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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