How to Change Kali Linux Hostname Using terminal

Posted: May 22, 2020 in Linux

Screen Shot 2020-05-22 at 7.54.36 AMKali Linux is becoming popular and more and more users are using it to try out different things. When installing kali, you get to choose a hostname, but in case you accepted the default hostname (kali) and later want to change it, here’s a How-to guide to change hostname in Kali Linux.

Now just changing hostname to something else might not be enough. How about we change hostname every time you boot your computer to a random one? That could be fun. It also helps to avoid suspicion from System Admins in your network to see “kali” in their network. Like BackTrack, SysAdmins doesn’t like Kali much (I mean why would they? Kali is designed to poke and prod around the network to find vulnerability). Even if you’re using Kali as your primary OS, it just raises eyebrows and you might get a visit from an over-conscious SysAdmin. So we will discuss all possible ways, change the hostname to something else permanently and change hostname randomly in each boot.

By default, my hostname (computer name) is kali as you see in the picture.

Image

Steps :

1. Open a Terminal (Ctrl+Alt+t) and enter the command “hostname” (without the quotes). This command shows the hostname of our machine.

Image

2. For changing the hostname, we use the same command “hostname” followed by your new desired hostname

 

 command usage :

hostname   new_host_name

Image

To view the change in a hostname, open a new terminal

Image

The above command is only applied to the specific session, so when you start the hostname service or restart your computer, the hostname will return to the old one (kali).

3. So, in order to make the hostname change permanent, we should edit the file named located in  /etc/hostname (this is where the hostnames are stored).

Use the editor command pico to edit that file. You can use any other editor command as you prefer.

Image

The file opens in the editor for editing.

Image

Delete the entry “kali” (in my machine) and enter your desired hostname.

Image

Press Ctrl+O and hit enter to save and press Ctrl+X to exit.

4. To check whether your hostname has changed or not, you can use the command “service hostname start” which restarts the service “hostname” or simply reboot your kali machine.

5. Now you have your new desired hostname permanent.

Posted by Shubham ;)

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.