Setting the Hostname and Timezone of Your Virtual Server

quickTips_blogHeaders_JavaScript

This is part two of this Quick Tip series. Click here to watch the first.

Now that you’ve setup and connected to your Linode, you need to give it a hostname. The hostname is the name of the machine, and can be set with just a couple commands.

Use the “echo” command, followed by the name of your server in quotes, followed by a greater than sign and /etc/hostname

Next, type in:
hostname -F /etc/hostname

You may also need to find and edit an additional file. To find out, type the following:
ls /etc/default/

If there dhcpcp file (in our case there isn’t), you will need to comment out the line that sets the hostname by placing the # symbol at the beginning of the line.

Now you’ll need to edit your hosts file with a text editor. You can use the built in nano editor by typing the following command:

nano /etc/hosts

Use the arrow keys to add in another line with the IP address of your server, then tab over and enter the name of your server. Save and exit the file.

Now you want to setup your timezone with the dpkg command:
dpkg-reconfigure tzdata

This will give you an interface to choose your geographic area and time zone of your server.

You now have a hostname and time zone for your Linode server.

Free Workshops

Watch one of our expert, full-length teaching videos. Choose from either HTML, CSS or Wordpress.

Start learning

Jim Hoskins

Jim Hoskins is an expert teacher at Treehouse. Twitter: @jimrhoskins

Comments

One comment on “Setting the Hostname and Timezone of Your Virtual Server

  1. you should point this article is about setting hostname and timezone on debian based servers, rhel/fedora based distros is done different, at least for the timezone