Properly configuring your VPS hostname and timezone is essential for system identification, logging, scheduled tasks, and network services. This guide covers how to set up both on Ubuntu, Debian, and RHEL-based distributions like AlmaLinux and Rocky Linux.
What You'll Learn
Prerequisites
- • A RamNode Cloud VPS running Ubuntu, Debian, AlmaLinux, or Rocky Linux
- • Root or sudo access to the server
- • SSH access configured and working
Hostname Overview
A hostname is a label that identifies your server on a network. It appears in system prompts, logs, and is used for network identification. You can use either a simple hostname or a Fully Qualified Domain Name (FQDN).
Simple Hostname
A single-word identifier for your server:
FQDN (Fully Qualified Domain Name)
Hostname with domain attached:
Tip: Use an FQDN if you're running a mail server or need proper SSL certificates. For testing or internal use, a simple hostname is sufficient.
Setting the Hostname
Using hostnamectl (Recommended)
The hostnamectl command is the modern way to set hostnames on systemd-based distributions (Ubuntu, Debian, AlmaLinux, Rocky Linux).
sudo hostnamectl set-hostname your-hostnamesudo hostnamectl set-hostname server.yourdomain.comUpdate /etc/hosts
After setting the hostname, update /etc/hosts to ensure proper local resolution:
sudo nano /etc/hostsAdd or modify these lines:
127.0.0.1 localhost
127.0.1.1 your-hostname.yourdomain.com your-hostname
# For IPv6:
::1 localhost ip6-localhost ip6-loopbackVerify Your Hostname
Confirm the hostname is set correctly:
# Display short hostname
hostname
# Display FQDN
hostname -f
# Display all information
hostnamectlTimezone Overview
Setting the correct timezone ensures accurate timestamps in logs, scheduled tasks (cron jobs), and application data. Most cloud servers default to UTC, which is recommended for servers.
Recommendation: Use UTC
For most server applications, UTC is recommended as it avoids daylight saving time complications and provides a consistent reference point across distributed systems.
Setting the Timezone
Check Current Timezone
# Display current timezone and time
timedatectl
# Or simply
dateList Available Timezones
# List all available timezones
timedatectl list-timezones
# Filter by region
timedatectl list-timezones | grep America
timedatectl list-timezones | grep Europe
timedatectl list-timezones | grep AsiaSet Timezone with timedatectl
# Set to UTC (recommended for servers)
sudo timedatectl set-timezone UTC
# Set to specific timezone examples
sudo timedatectl set-timezone America/New_York
sudo timedatectl set-timezone Europe/London
sudo timedatectl set-timezone Asia/Tokyo
# Verify the change
timedatectlAlternative: Using Symbolic Link
On older systems without timedatectl:
# Remove existing localtime
sudo rm /etc/localtime
# Create symbolic link to desired timezone
sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
# Update timezone file (Debian/Ubuntu)
echo "America/New_York" | sudo tee /etc/timezoneNTP Time Synchronization
Network Time Protocol (NTP) keeps your server's clock synchronized with authoritative time servers. Accurate time is critical for logging, security certificates, and distributed systems.
Using systemd-timesyncd (Default)
Most modern distributions use systemd-timesyncd for time synchronization:
# Check NTP status
timedatectl show-timesync --all
# Enable NTP synchronization
sudo timedatectl set-ntp true
# Verify synchronization status
timedatectl statusUsing chrony (Recommended for Servers)
Chrony is more accurate and handles network interruptions better than systemd-timesyncd:
sudo apt install chrony -y
sudo systemctl start chronyd
sudo systemctl enable chronydsudo dnf install chrony -y
sudo systemctl start chronyd
sudo systemctl enable chronyd# Check synchronization status
chronyc tracking
# View time sources
chronyc sources -vManual Time Sync
For one-time synchronization:
# Using chrony
sudo chronyc makestep
# Or using ntpdate (if installed)
sudo ntpdate pool.ntp.orgBest Practices
Ensure your hostname matches your reverse DNS (PTR) record for email deliverability.
Use a naming convention (e.g., web01, db01, cache01) to make management easier.
UTC avoids daylight saving time issues and provides consistency across distributed systems.
Always keep time synchronized. Drift can cause issues with SSL certificates, logs, and authentication systems.
Chrony handles intermittent network connections better and synchronizes faster after system boot.
Important: If you change the hostname on a running server, some applications may require a restart to recognize the change. Reboot if you encounter issues.
