Tutorial: Get started with Amazon EC2 Linux instances
Use this tutorial to get started with Amazon Elastic Compute Cloud (Amazon EC2). You'll learn how to launch, connect to, and use a Linux instance. An instance is a virtual server in the AWS cloud. With Amazon EC2, you can set up and configure the operating system and applications that run on your instance.
To get started with a Windows instance, see Getting started with Amazon EC2 Windows instances.
When you sign up for AWS, you can get started with Amazon EC2 using the AWS Free Tier
Contents
Overview
The instance is an Amazon EBS-backed instance (meaning that the root volume is an EBS volume). You can either specify the Availability Zone in which your instance runs, or let Amazon EC2 select an Availability Zone for you. When you launch your instance, you secure it by specifying a key pair and security group. When you connect to your instance, you must specify the private key of the key pair that you specified when launching your instance.

Tasks
To complete this tutorial, perform the following tasks:
Related tutorials
-
If you'd prefer to launch a Windows instance, see this tutorial in the Amazon EC2 User Guide for Windows Instances: Get started with Amazon EC2 Windows instances.
-
If you'd prefer to use the command line, see this tutorial in the AWS Command Line Interface User Guide: Using Amazon EC2 through the AWS CLI.
Prerequisites
Before you begin, be sure that you've completed the steps in Set up to use Amazon EC2.
Step 1: Launch an instance
You can launch a Linux instance using the AWS Management Console as described in the following procedure. This tutorial is intended to help you launch your first instance quickly, so it doesn't cover all possible options. For more information about the advanced options, see Launch an instance using the Launch Instance Wizard. For information about other ways to launch your instance, see Launch your instance.
To launch an instance
-
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
From the console dashboard, choose Launch Instance.
-
The Choose an Amazon Machine Image (AMI) page displays a list of basic configurations, called Amazon Machine Images (AMIs), that serve as templates for your instance. Select an HVM version of Amazon Linux 2. Notice that these AMIs are marked "Free tier eligible."
-
On the Choose an Instance Type page, you can select the hardware configuration of your instance. Select the
t2.micro
instance type, which is selected by default. Thet2.micro
instance type is eligible for the free tier. In Regions wheret2.micro
is unavailable, you can use at3.micro
instance under the free tier. For more information, see AWS Free Tier. -
On the Choose an Instance Type page, choose Review and Launch to let the wizard complete the other configuration settings for you.
-
On the Review Instance Launch page, under Security Groups, you'll see that the wizard created and selected a security group for you. You can use this security group, or alternatively you can select the security group that you created when getting set up using the following steps:
-
Choose Edit security groups.
-
On the Configure Security Group page, ensure that Select an existing security group is selected.
-
Select your security group from the list of existing security groups, and then choose Review and Launch.
-
-
On the Review Instance Launch page, choose Launch.
-
When prompted for a key pair, select Choose an existing key pair, then select the key pair that you created when getting set up.
Warning Don't select Proceed without a key pair. If you launch your instance without a key pair, then you can't connect to it.
When you are ready, select the acknowledgement check box, and then choose Launch Instances.
-
A confirmation page lets you know that your instance is launching. Choose View Instances to close the confirmation page and return to the console.
-
On the Instances screen, you can view the status of the launch. It takes a short time for an instance to launch. When you launch an instance, its initial state is
pending
. After the instance starts, its state changes torunning
and it receives a public DNS name. (If the Public IPv4 DNS column is hidden, choose the settings icon () in the top-right corner, toggle on Public IPv4 DNS, and choose Confirm.
-
It can take a few minutes for the instance to be ready so that you can connect to it. Check that your instance has passed its status checks; you can view this information in the Status check column.
Step 2: Connect to your instance
There are several ways to connect to your Linux instance. For more information, see Connect to your Linux instance.
You can't connect to your instance unless you launched it with a key pair for
which you have the .pem
file and you launched it with a
security group that allows SSH access from your computer. If you can't connect
to
your instance, see Troubleshoot connecting to your
instance for assistance.
Step 3: Clean up your instance
After you've finished with the instance that you created for this tutorial, you should clean up by terminating the instance. If you want to do more with this instance before you clean up, see Next steps.
Terminating an instance effectively deletes it; you can't reconnect to an instance after you've terminated it.
If you launched an instance that is not within the AWS Free Tiershutting down
or terminated
.
To keep your instance for later, but not incur charges, you can stop the
instance now and then start it again later. For more information, see Stop and start your instance.
To terminate your instance
-
In the navigation pane, choose Instances. In the list of instances, select the instance.
-
Choose Instance state, Terminate instance.
-
Choose Terminate when prompted for confirmation.
Amazon EC2 shuts down and terminates your instance. After your instance is terminated, it remains visible on the console for a short while, and then the entry is automatically deleted. You cannot remove the terminated instance from the console display yourself.
Next steps
After you start your instance, you might want to try some of the following exercises:
-
Learn how to remotely manage your EC2 instance using Run Command. For more information, see AWS Systems Manager Run Command in the AWS Systems Manager User Guide.
-
Configure a CloudWatch alarm to notify you if your usage exceeds the Free Tier. For more information, see Tracking your AWS Free Tier usage in the AWS Billing and Cost Management User Guide.
-
Add an EBS volume. For more information, see Create an Amazon EBS volume and Attach an Amazon EBS volume to an instance.
-
Install the LAMP stack. For more information, see Tutorial: Install a LAMP web server on Amazon Linux 2.