Set Hostname & Timezone

Ubuntu: Set Hostname & Timezone

Setting the hostname and timezone ensures your server is properly identified and logs are accurate. This guide explains how to configure hostname and timezone on Ubuntu servers.


Step 1: Check Current Hostname

hostnamectl

This displays the current hostname and related information.


Step 2: Set a New Hostname

sudo hostnamectl set-hostname myserver

Replace myserver with your desired hostname.


Step 3: Verify Hostname Change

hostnamectl

You should see the updated hostname.


Step 4: Check Current Timezone

timedatectl

This shows the current system time, timezone, and synchronization status.


Step 5: List Available Timezones

timedatectl list-timezones

Scroll or search for your desired timezone (e.g., Asia/Kolkata).


Step 6: Set Timezone

sudo timedatectl set-timezone Asia/Kolkata

Replace Asia/Kolkata with your preferred timezone.


Step 7: Verify Timezone Change

timedatectl

You should see the updated timezone applied.


Best Practices

  • Use meaningful hostnames (e.g., web01, db01) for easier identification
  • Always set timezone to match your region or client’s region
  • Ensure NTP (Network Time Protocol) is enabled for accurate time sync
  • Check logs after timezone changes to confirm consistency

Note: HostPalace servers are globally distributed, so setting the correct hostname and timezone ensures smooth operations and accurate monitoring.