
Hey there! In this post, I’m taking you on my journey of launching an Amazon EC2 Linux instance on the cloud. This AWS EC2 Tutorial For Beginners is written in my own casual style—honest, energetic, and downright fun. I will show you exactly how to set up a server, attach an Elastic IP, and manage it like a pro. This is one of the crucial guides towards your path to mastering AWS. So, buckle up and let’s dive right in!
What Are Regions in AWS?
Before you jump in, let’s talk about regions. Amazon’s data centers are spread out all over the world, and each of these areas is known as a “region.” Every region may offer different EC2 resources and pricing. I learned early on that picking the right region can save you time and money. If you are on the AWS free usage tier or just getting started, the region shouldn’t be a huge concern—pick one close to your target audience. See all available regions to learn more.
Create A New AWS EC2 Linux Instance:
Log Into Your AWS Console:
Log into your AWS account and navigate straight to the EC2 service console. The EC2 dashboard gives you a quick snapshot of your instances, Elastic IPs, and EBS volumes.

Head Over to the Instances Page:
Even if you have no instances running yet, click the “Instances” link on the left sidebar. You’ll see an empty window ready for your new launch.
Launch a New Instance:
Hit the “Launch Instance” button. You’ll notice three wizard options: Classic, Quick Launch, and AWS Marketplace. I always go with the Classic Wizard because it lets me control every detail.
Choose Your Operating System:
Now, here’s an important update: I recommend Amazon Linux for its seamless AWS integration and free tier eligibility. If you’re more into Ubuntu, you can opt for the latest Ubuntu Server. Either way, pick the one that suits you best.
- Amazon Linux (recommended for free tier)
- Ubuntu Server (Latest) LTS as an alternative
Configure Instance Details:
Next, the wizard asks for instance details. Enter a simple key-value pair for the name (e.g. “MyAWSInstance”) and leave most options as default. I recommend one micro instance with an automatically assigned availability zone as a starter —no fuss is needed here.
Storage Configuration:
AWS gives you a default of 8GB root storage for Linux micro instances. That’s more than enough to get started. Don’t worry about EBS storage at this stage; you can tweak it later if you need extra space.
Advanced Options & Security:
Skim through the advanced options. There’s an option to “prevent accidental termination,” which you can activate for peace of mind. On the security side, I simply used the default security group. You can always modify these settings later if your needs change.
Review & Launch:
Finally, review all settings. Once you are 100% sure everything is set, click the “Launch” button. The console then shows a new instance coming to life.
And just like that—congratulations! Your EC2 Linux instance was up and running and ready for action.
Managing Your AWS EC2 Instance:
Controlling your instance is a breeze. Whether you want to start, stop, reboot, or terminate your server, you can simply select it and choose the corresponding action from the “Actions” dropdown. Here’s a quick rundown:
Start/Stop/Reboot/Terminate: Use the Actions menu(with the checkbox for the intended instance selected) or right-click the instance.
Tip: Remember that AWS bills free tier usage by hours, not by the number of instances. So, keeping some instances stopped is a smart move.
Warning:
Some settings auto-terminate an instance on shutdown. Make sure that’s actually what you want.
Attaching an Elastic IP To Your EC2 Instance:
One thing I learned the hard way: the default public DNS name changes whenever you stop, start, or reboot your instance. To avoid this headache, I recommend attaching an Elastic IP to the instance. However, keep in mind that it comes with a cost(See Elastic IP documentation). Here’s how you can do it:
- Navigate to Elastic IPs:
In the left menu under “NETWORK & SECURITY,” click on “Elastic IPs.” - Allocate a New Address:
Click the “Allocate New Address” button and confirm the prompt. Instantly, a new IP appears in your list. - Associate the IP:
Select your new IP and click “Associate Address.” In the dialogue box, pick your instance and hit OK. Now your instance is permanently accessible through this dedicated IP address.

Connecting to your AWS EC2 Instance:
Method 1: Connecting via SSH (The Classic Way)
If you’ve been around the block with Linux servers, you already know that SSH is the bread and butter of remote access. For those who don’t, SSH stands for Secure Shell, and it’s how we securely talk to our EC2 instances from our local machine.
Here’s how I do it:
- Grab Your Key Pair :
When you launch your EC2 instance, AWS gives you a key pair (a.pem
file). This little file is your golden ticket to the instance. Keep it safe—it’s like the keys to your house. - Set Permissions on the Key :
Before you can use the.pem
file, you’ve got to set the right permissions. Open your terminal and type:chmod400 /path/to/your-key.pem
- Connect Using SSH :
Now comes the fun part. Run this command:ssh -i /path/to/your-key.pem ec2-user@your-instance-ip
. - Celebrate! :
If everything goes smoothly, you’re in! You should see a welcome message from your instance.
Method 2: Connecting via AWS CLI (The Modern Approach)
Now, here’s where things get exciting. The AWS CLI (Command Line Interface) is a game-changer for managing AWS resources, including EC2. It’s fast, efficient, and makes you feel like a cloud wizard.
Here’s how I use the AWS CLI to connect to my EC2 instance:
- Install the AWS CLI :
If you haven’t installed it yet, just head over to the AWS CLI documentation and follow the instructions. Trust me, it’s worth it. - Configure Your Credentials :
Once installed, run this command to set up your credentials:bashCopy1aws configure. When prompted, enter your Access Key, Secret Key, region, and output format. - Use EC2 Instance Connect :
AWS has this nifty feature called EC2 Instance Connect, which lets you push your SSH key directly to the instance. Here’s the command:aws ec2-instance-connect send-ssh-public-key --instance-id your-instance-id --availability-zone your-az --instance-os-user ec2-user --ssh-public-key file://~/.ssh/id_rsa.pub
After that, you can SSH into your instance as usual.
Why I Love This Method :
It’s secure and quick and eliminates the hassle of manually managing key pairs. Plus, it works even if you lose your .pem
file!
Troubleshooting Common Issues
Let’s face it—things don’t always go as planned. Here are some common hiccups I’ve encountered and how I fixed them:
- “Permission Denied” Errors :
Double-check your key permissions. Did you runchmod 400
? Also, ensure you’re using the correct username for your AMI. - Timeout When Connecting :
Check your security group settings. Make sure port 22 is open for SSH traffic.
If you have come this far, congratulations! You have now launched and connected to your first AWS EC2 instance. Thus, you learned about the most foundational lesson towards mastering AWS Cloud.
FAQs: Quick Answers to Common AWS EC2 Questions
Q: What is an EC2 instance?
A: You can use your virtual server in the cloud to run applications, websites, and more.
Q: How do I launch an EC2 instance?
A: Log into your AWS console, select EC2, and follow the Classic wizard steps as I outlined above.
Q: Why should I attach an Elastic IP?
A: It gives you a permanent, static IP address, so your server’s address won’t change when you restart it.
Q: Which operating system should I choose?
A: I went with Amazon Linux for its tight AWS integration and free tier benefits, but Ubuntu Server or whatever you are most comfortable with should work just fine.
Final Thoughts
I hope you are excited about setting up an EC2 instance and getting started with your next big project. This AWS EC2 Tutorial for Beginners is just a starting point for exploring the vast world of AWS Cloud services, which unlock superpower applications at any scale! Stay tuned for future articles. Happy Cloud Development!
Discover more from CodeSamplez.com
Subscribe to get the latest posts sent to your email.
[…] layers that need peeling back as you learn more, like Auto Scaling and instance types. We covered the essentials in the EC2 Guide for Beginners article and will cover others in future articles. Stay […]