How to Set or Change System Hostname in Linux

Newer version of different Linux distributions such as latest Ubuntu, Debian, CentOS, Fedora, RedHat, etc. comes with systemd, a system and service manager that provides a hostnamectl command to manage hostnames in Linux.

To set system hostname on SystemD based distributions, we will use hostnamectl command as shown:

hostnamectl set-hostname new_hostname.com


For Older Linux distributions, which uses SysVinit in short init, can have their hostnames changed by simply editing the hostname file located in:

nano /etc/hostname

For example:

1.2.3.4 new_hostname.com

On RHEL/CentOS based systems that use init, the hostname is changed by modifying:

nano /etc/sysconfig/network

For example:
HOSTNAME="new_hostname.com"

You can check the hostname using the next command:

hostname

  • hostname, хостнейм, хост, host
  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

Как создать поддомен в ISPmanager?

В ISPmanager нету такого понятия как "поддомен". Это все домены, только разного уровня.Перейдите...

IP-spoofing

IP-спуфинг- Вид хакерской (Ddos) атаки, заключающийся в использовании чужого IP-адреса с целью...

Команды du и df показывают разный объем доступного дискового пространства. Что происходит?

Вам нужно разобраться, что на самом деле делают команды du и df. du проходит по дереву каталогов,...

Режим Recovery

Режим Recovery необходим в случаях, когда: сервер не запускается в обычном режиме. Чтобы найти...

What is SWAP?

Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which...