mikenunez
3/7/2019 - 8:29 AM

Set Hostname and Timezone servers

Set the HostnamePermalink

A hostname is used to identify your device in an easy-to-remember format. The hostname is stored in the /etc/hostname file. Your system’s hostname should be something unique. Some people name their servers after planets, philosophers, or animals. Note that the hostname has no relationship to websites or email services hosted on it, aside from providing a name for the system itself. Your hostname should not be “www” or anything too generic. If you want to assign your system a fully qualified domain name, see our guide on using your system’s hosts file.

Once you’re done, you can verify by running the command hostname.

Arch / CentOS 7 / Debian 8 / Fedora / Ubuntu 16.04 and abovePermalink

Replace example_hostname with one of your choice.

hostnamectl set-hostname example_hostname

Debian 7 / Slackware / Ubuntu 14.04Permalink

Replace example_hostname with one of your choice.

echo "example_hostname" > /etc/hostname
hostname -F /etc/hostname

CentOS 6Permalink

Replace hostname with one of your choice.

echo "HOSTNAME=example_hostname" >> /etc/sysconfig/network
hostname "hostname"

GentooPermalink

Enter the following commands to set the hostname, replacing example_hostname with the hostname of your choice:

echo "HOSTNAME=\"example_hostname\"" > /etc/conf.d/hostname
/etc/init.d/hostname restart

Update /etc/hostsPermalink

The hosts file, located at /etc/hosts, creates static associations between IP addresses and hostnames, with higher priority than DNS. Open this file in a text editor and add a line for your Linode’s public IP address. You can associate this address with your Linode’s Fully Qualified Domain Name (FQDN) if you have one, and with the local hostname you set in the steps above. In the example below, 203.0.113.10 is the public IP address, hostname is the local hostname, and hostname.example.com is the FQDN.

/etc/hosts

|

1
2

|

127.0.0.1 localhost.localdomain localhost
203.0.113.10 hostname.example.com hostname

|

If you have IPv6 enabled on your Linode, you may also want to add an entry for your IPv6 address:

/etc/hosts

|

1
2
3

|

127.0.0.1 localhost.localdomain localhost
203.0.113.10 hostname.example.com hostname
2600:3c01::a123:b456:c789:d012 hostname.example.com hostname

|

The value you assign as your system’s FQDN should have an “A” record in DNS pointing to your Linode’s IPv4 address. For Linodes with IPv6 enabled, you should also set up an “AAAA” record in DNS pointing to your Linode’s IPv6 address. For more information on configuring DNS, see Adding DNS Records.

For more information about the hosts file and how to configure it, see Using your System’s hosts File

Set the TimezonePermalink

By default, your Linode will be set to UTC time. You may want to change this to the timezone you live in, or where a majority of your users live, to make log file timestamps more sensible.

Debian / UbuntuPermalink

dpkg-reconfigure tzdata

Arch Linux / CentOS 7 / FedoraPermalink

  1. View a list of available time zones:

    timedatectl list-timezones
    
    
  2. Use the Up, Down, Page Up and Page Down keys to navigate. Find the time zone you want. Remember it, write it down, or copy it as a mouse selection. Then press q to exit the list.

  3. Set the time zone:

    timedatectl set-timezone 'America/New_York'
    
    

GentooPermalink

  1. View a list of available time zones:

    ls /usr/share/zoneinfo
    
    
  2. Write the selected time zone to the /etc/timezone file:

    echo "EST" > /etc/timezone
    
    
  3. Configure the sys-libs/timezone-data package, which will set /etc/localtime appropriately:

    emerge --config sys-libs/timezone-data
    
    

Check the TimePermalink

View the current date and time according to your server.

date

Thu Feb 16 12:17:52 EST 2018