Debian How to Change your Hostname in Debian

  • Hi Guest, we offer coupons to get 2 days of free vip on every 1st of the month. Please ask in the chat for further assistant.


EScripts | Volt
Staff member
Feb 26, 2015
Find Current Hostname
There are different ways to find hostname. But the most easy and stable way is printing related host name configuration. Host name configuration is stored in /etc/hostname which is very easy to find. We will print this configuration file like below.
cat /etc/hostname

Find Current Hostname with hostnamectl Command
hostnamectl is a new tool in order to manage host name configuration. We can print current hostname just providing hostnamectl command like below. As we can more information can be found in the output like Operating system, machine UID etc.

Change Hostname Temporary
There is command named hostname which is used to change hostname temporarily. We can provide the name we want to set. But we should have root privileges for host name change.
sudo hostname yournamehere

Change Host name Permanently
We can change hostname permanatly too. Previous example will change hostname for current power up. After a reboot the host name will be reverted back. We will edit the hostname configuration file /etc/hostname and put whatever we want.
sudo echo "yournamehere" > /etc/hostname

Change Host name with hostnamectl
hostnamectl command provides different options to list and set host name and related information. We will use set-hostname option in order to change host name. We will set host name yournamehere like below.
sudo hostnamectl set-hostname yournamehere