Set Up a Linode Compute Instance: Step-by-Step Guide

Linode (Akamai Cloud) offers powerful cloud hosting with lightning-fast performance, transparent pricing, and a user-friendly interface, making it ideal for everything from personal projects to large-scale deployments.

Ready to unlock the full potential of your cloud infrastructure? Let's dive into setting up, backing up, and restoring your Linode compute instances!

Prerequisites #

Before you begin, ensure you have:

  • A Linode (Akamai) account.
  • SSH access to your terminal.
  • Basic knowledge of Linux commands.

Set Up Compute Instance #

  • In cloud computing, a compute instance is basically the same as a virtual machine (VM). It's a virtual computer with its own CPU, RAM, storage, operating system, and network access.

  • Cloud providers like Linode, AWS, and GCP use the term compute instance to describe a VM running in their infrastructure. The term reflects a cloud-focused way of thinking, but functionally, it's a virtual machine.

Step 1: Create Linode #

  1. Log in to Linode Cloud Manager.
  2. Go to Compute > Linodes and click Create Linode.
  3. Configure:
    • Region: Nearest to your location
    • OS: Ubuntu (latest LTS)
    • Plan: Shared CPU Nanode 1GB
    • Label: Provide descriptive label (example: prod-web-blog)
    • Root password: Strong and secure
    • Disk Encryption: Enable
  4. Click Create Linode.

Best practices for labels:

Practice Description
Use consistent naming conventions Create a standard format for all labels, such as <environment>-<service>-<description>. Example: prod-web-blog.
Include environment information Indicate if the Linode is for prod, dev, stage, or test.
Reflect function or role Specify the purpose of the Linode, such as db, web, cache, or proxy.
Include location (optional) If you deploy in multiple data centres, include the datacentre or region code, like lon1, fra1, nyc1.
Keep it human-readable Avoid overly cryptic labels. A person should understand the label quickly.
Use lowercase letters Lowercase is standard practice and avoids confusion in scripts and automation.
Avoid special characters Use hyphens - to separate words, and avoid underscores _, spaces, and special symbols.
Instance numbering (optional) Add sequential numbers if you have multiple similar Linodes. Example: prod-api-lon1-02.

Examples:

  • Production web server in London: prod-web-lon1-01
  • Development database in Frankfurt: dev-db-fra1-01

Step 2: Set Up Firewall #

Firewall label: use a format like prod-web-fw or dev-db-fw.

  1. Go to Networking > Firewalls
  2. Click Create Firewall
  3. Configure:
    • Label: Provide descriptive label (example: prod-web-fw)
    • Default inbound policy: Drop
    • Default outbound policy: Drop
    • Linodes: Select target Linode(s)
  4. Add Custom rules as needed
  5. Click Save Changes

Custom Rules Configuration

Inbound rules:

Service Protocol Port Sources Action
SSH TCP 22 All IPv4, All IPv6 Accept
HTTP TCP 80 All IPv4, All IPv6 Accept
HTTPS TCP 443 All IPv4, All IPv6 Accept

Outbound rules:

Service Protocol Port Sources Action
DNS TCP 53 All IPv4, All IPv6 Accept
DNS UDP 53 All IPv4, All IPv6 Accept
HTTP TCP 80 All IPv4, All IPv6 Accept
HTTPS TCP 443 All IPv4, All IPv6 Accept
SMTP TCP 587 All IPv4, All IPv6 Accept

For package updates (e.g. apt), ensure outbound HTTP/HTTPS is allowed.

Step 3: Access Instance via SSH #

Log in as root:

bash
ssh root@<public_ipv4>

Step 4: Update Packages #

bash
sudo apt update && sudo apt upgrade -y

Step 5: Create a Non-Root Sudo User #

Create user with sudo privileges:

bash
adduser <user>
usermod -aG sudo <user>
  • Follow the prompt to set a password.
  • Provide a full name when asked. Leave other fields empty by pressing Enter.

Explanation:

adduser <user>

  • Purpose: Creates a new user account
  • What it does:
    • Adds the user to the system
    • Creates a home directory (/home/<user>)
    • Sets default shell (usually /bin/bash)
    • Prompts for password and optional user info (full name, etc)

usermod -aG sudo <user>

  • Purpose: Grants user sudo (administrative) privileges
  • Breakdown:
    • usermod: Modifies an existing user
    • -aG sudo: Appends (-a) the user to the sudo group (-G)

Verify group membership:

bash
groups <user>

The user will be able to run admin commands using sudo.

Log out of the root session:

bash
logout

Log in as the new non-root user:

bash
ssh <user>@<public_ipv4>

Run a test command with sudo to confirm access:

bash
sudo whoami

Expected output: root (indicates sudo is working correctly).

Step 6: Set Hostname #

Set the system hostname using hostnamectl:

bash
sudo hostnamectl set-hostname <hostname>

Example:

bash
sudo hostnamectl set-hostname prod-web-blog

Notes

  • The shell prompt will reflect the new hostname after re-login or reboot.
  • To apply immediately in the current session:
bash
exec bash
  • Verify the change:
bash
hostnamectl

Step 7: Set Timezone #

Configure the system timezone:

bash
sudo dpkg-reconfigure tzdata

Use the interactive menu to select your region and city.

Verify time settings:

bash
date

or:

bash
timedatectl

timedatectl shows detailed status including timezone, system clock, and NTP sync.