Change hostname on Kali Linux

In this article, we are going to learn how to change hostname on Kali Linux. The hostname of a Linux system is important because it is an identification of a device when we are connected with the network. And hostname is also shone in the terminal when we are using the terminal in the Linux machine. You can change the hostname as you want, so let’s start how to change hostname on Kali Linux:

Change Hostname on Kali Linux

Check hostname

We can check the current hostname by using the following command:

[[email protected] ~ ]$ hostname

Check hostname

Change the Hostname

If we want to change the hostname we have to edit the two files. First, of all, we have to change the /etc/hostname file.

[email protected] ~ ]$ sudo nano /etc/hostname
Change the Hostname

The second file is /etc/hosts, we have to replace the new hostname with the old one.

[[email protected] ~ ]$ sudo nano /etc/hosts
Chnage Hosts file

That’s all there is to it. Now you have to restart your system. You can restart by command or you can use GUI way.


  • This article was written only for educational purposes.
  • The author can not be held any responsibility for damage caused by the use of these resources.
  • You will not use this information to gain unauthorized access or any other legal activity.

Read also Disclaimer

If you are using any illegal activities using these techniques can’t hold any responsibility for your action.
This blog only for educational purposes where you will learn about Kali Linux how it works and how you can install any tools in Kali Linux.


If you have any questions about this article, any feedback, suggestions, or if you want to share your thoughts, please feel free to comment below.
If you want to speak with us directly you can Contact Us.

About The Author



  1. AvatarAjay Prashar

    I will test the process you describe as restated below:
    1. hostname
    2. sudo nano /etc/hostname
    3. sudo nano /etc/hosts

    Do you suspect that if you change the order just ever so sightly, it will render your Kali machine unusable?:
    1. hostname
    2. sudo nano /etc/hosts
    3. sudo nano /etc/hostname

    I will test this again, as I did this morning, later on tonight but I encountered unresolvable issues as the command “sudo” would not work due to the mismatch of the hostname due to the step 2. I also rebooted with miserable results on a new install.

Leave a Reply

Your email address will not be published.