Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Change Hostname in CentOS/RHEL 8 - DesignLinux

May 29 2020
designlinux 0 Comments

Setting up a hostname is one of the quintessential tasks when setting up a server. A hostname is a name that is assigned to a PC in a network and helps in uniquely identifying it.

There are various ways of setting up a hostname in CentOS/RHEL 8 and we are going to look at each in turn.

To display the system’s hostname, run the command.

$ hostname
Check RHEL 8 Hostname

Check RHEL 8 Hostname

Additionally, you can execute the hostnamectl command as shown:

$ hostnamectl
Check System Hostname

Check System Hostname

Setting a Hostname in RHEL 8

To configure a hostname, login and use the hostnamectl command as shown:

$ sudo hostnamectl set-hostname 

For example, to set the hostname to tecmint.rhel8 execute the command:

$ sudo hostnamectl set-hostname tecmint.rhel8
Set System Hostname

Set System Hostname

You can later verify if the new hostname has been applied to your system by running the hostname or hostnamectl commands.

$ hostname
$ hostnamectl
Confirm System Hostname

Confirm System Hostname

Next, add the record for the hostname in the /etc/hosts file.

127.0.0.1	tecmint.rhel8

This automatically adds an entry by default to the /etc/hostname file.

Save and exit the text editor.

Finally, restart the networking service for the changes to come into effect.

$ sudo systemctl restart NetworkManager

Alternatively, you can use nmtui command to set or change the hostname of your system as shown.

$ sudo nmtui
Set System Hostname

Set System Hostname

Enter your new hostname.

Add New Hostname

Add New Hostname

Finally, restart the systemd-hostnamed service to apply recent changes.

$ sudo systemctl restart systemd-hostnamed

And this concludes this guide on how to change or set a hostname on CentOS/RHEL 8. We hope you found this guide helpful.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: CentOS Tips, RHEL Tips

10 Top Most Popular Linux Distributions of 2020

Prev Post

rdiff-backup – A Powerful Incremental Backup Tool Now Supports Python 3

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 4
  • 530
  • 612,709

DesignLinux.com © All rights reserved

Go to mobile version