Change Server hostname/Timezone/Date on RHEL/CentOS 8/7

Having the right time and server hostname is a significant part of Linux Servers. Most applications will reference the system’s local time while writing logs and reporting the event’s time. The server hostname is also used for local DNS resolution, and for application configuration. This article will explain the steps to set or change a Server’s hostname, Timezone and Date on RHEL/CentOS server.

Useful Articles:

Server Hostname Status:
Use the hostnamectl tool to set or change the server hostname. Run the below-mention command to check hostname status.

# hostnamectl status

Set Server Hostname:
You can set the hostname on your server using the following command.


# hostnamectl set-hostname <hostname>

In place please mention the hostname you want to configure.

# hostnamectl set-hostname webserver.local

After changing the hostname using the hostnamectl command you can check the status of the hostname.

# hostnamectl

Set Pretty Hostname:
You can also set the Pretty hostname with quotation marks.

# sudo hostnamectl set-hostname "Anuket Jain System" --pretty

After changing the pretty hostname using the hostnamectl command you can check the status.

$ hostnamectl

Clear System Hostname:
Clear a particular system hostname and revert to the changes:

# hostnamectl set-hostname ""

Configure Timezone:
We use timedatectl command to change the current timezone of the server. First list all timezones using the mentioned command.

# timedatectl list-timezones

Display the Current Date and Time:
To display the current system date and time run the mentioned command.

# timedatectl status

Now use the following command to change the timezone to America/New_York.

# timedatectl set-timezone America/New_York

Change the Current Time:
Set the current time on your server using the command syntax:


# timedatectl set-time HH:MM:SS

For example, changing the current time to 7:52 p.m.

# timedatectl set-time 19:52:00

Change the Current Date:
The current date can be changed by running the command syntax.

# timedatectl set-time "yyyy-MM-dd hh:mm:ss"

For example, changing the current time and date to 2022-01-21 05:11 AM.

# timedatectl set-time "2022-01-21 05:11:00"

Enjoy it!

No Responses

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.