How to change hostname on Debian based Linux

A name for your computer. Also on Linux

In computer networking, a hostname is a label that is assigned to a device connected to a computer network and that is used to identify the device in various forms of electronic communication such as the World Wide Web, e-mail or Usenet. Hostnames may be simple names consisting of a single word or phrase, or they may be structured.

Hostname on Wikipedia

Hostname is a human-readable address of a device

So, basically, the hostname is the name of your computer (or device, or more…) and you can change it to what you want. It’s identify your system on the network and allow to you to do operations to/from your host.

To edit your hostname, open a terminal window and edit the hostname file. For graphical editor, type:

sudo gedit /etc/hostname

For cli-editor, type:

sudo nano /etc/hostname

The /etc/hostname file is very difficult to understand. There are a lot of code instructions and many lines of guru-based characters. Oh, it’s a joke. The file contains only one simple thing: the name of your computer, e.g. your hostname. So, delete the old name and put your new one.

The hostname is also stored in the /etc/hosts file, so you need to change the hostname in your hosts file, too.
In terminal, type:

sudo nano /etc/hosts

And put your hostname near

Save file and reboot your pc because this doesn’t take effect immediately.

If you like to understand a bit more about the command line interface and Linux networking, I suggest you:
How Linux Works: What Every Superuser Should Know

Enjoy your new hostname experience!

Leave a Reply

Your email address will not be published. Required fields are marked *