How To Change Linux Hostname In Ubuntu, Debian, Mint, Kali, CentOS, RedHat?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-change-linux-hostname-in-ubuntu-debian-mint-kali-centos-redhat/
PINTEREST
PINTEREST
INSTAGRAM

Hostname is used to name the systems. Normally the computer networks work with IP addresses in order to identify and communicate. But hostname provides human friendly way to name, identify, communicate with other systems.

Example Hostname

Hostname is just a meaningful word for the system administrators to name a system. For example we can use db1 for first database server or app3 for the third application server.

Default Hostname

Hostnames generally set during the system installation. But may change after the installation. Different Linux distributions uses different default hostnames during installation. Here are some of them.

Debian

Ubuntu:

Fedora:

CentOS:

Print Hostname with hostname Command

There are different ways to print default hostname of the system. hostname command is the most known and popular way in order to print hostname of the current system. This command will work on all Linux distributions like Debian, Ubuntu, Mint, Kali, CentOS, RedHat, Fedora etc.

Print Hostname with hostname Command
Print Hostname with hostname Command

As we can see the hostname of the given system is poftut1

Print Hostname with hostnamectl Command

There is a new command which is supported by all popular Linux distributions like Debian, Ubuntu, Mint, Kali CentOS, RedHat, Fedora. We can use hostnamectl command which will provide the hostname of the current system and more like Chassis , Operating System etc.

Print Hostname with hostnamectl Command
Print Hostname with hostnamectl Command

Change Hostname For Ubuntu, Debian, Mint, Kali

Now we will start to learn how to change hostname of the deb based Linux distributions like Ubuntu, Debian, Mint, Kali. These distributions stored hostname settings in /etc/hostname file. So changing this file will change hostname but this will require a reboot to make changes affect.

LEARN MORE  How To Download and Install Kali Security and Penetration Test Linux Distribution?

In this example we will change hostname to the POF1 . We will also use sudo because hostname change operation requires root privileges.

Change Hostname For CentOS, RedHat

Hostname configuration of rpm based disributions like CentOs, RedHat, Fedora are stored in /etc/sysconfig/network . HOSTNAME line provides the hostname of the current system. Example configuration file is like below.

Just put the hostname you want to set to the poftut . But there is also domain name part which is domainname.com . We can set as default or change according to our settings. But if we do not need we can set whatever we want.

In order to make change affect we need to restart network services with the following command.

Change Hostname with sysctl Command For Ubuntu, Debian, Mint, Kali, CentOS, RedHat

sysctl is a command use to configuration low level settings of a Linux system and kernel. We can use it to set hostname. In this example we will set as poftut1 .

Change Hostname with hostnamectl Command For Ubuntu, Debian, Mint, Kali, CentOS, RedHat

We can also use hostnamectl command in order to change current hostname configuration. In this case we will use set-hostname parameter. In this example we will set the hostname as poftut1

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-change-linux-hostname-in-ubuntu-debian-mint-kali-centos-redhat/
PINTEREST
PINTEREST
INSTAGRAM