AWS CLI Full Guide: Installation, Configuration, and Usage


The AWS Command Line Interface (CLI) is a powerful tool that allows you to interact with AWS services directly from your terminal. Whether you're managing EC2 instances, S3 buckets, or IAM policies, the AWS CLI simplifies automation and scripting.
In this guide, we'll cover:
Logging into a VM (Linux/Windows)
Installing and Configuring AWS CLI
Basic AWS CLI Commands and Usage
1. Logging into a Virtual Machine (VM)
Before installing the AWS CLI, you need to access your VM. Here's how:
For Linux (SSH)
ssh username@your-vm-ip -i /path/to/your-key.pem
Replace
username
with your VM’s username (e.g.,ubuntu
,ec2-user
).Replace
your-vm-ip
with the public IP of your VM.Ensure your key file (
key.pem
) has the correct permissions:chmod 400 /path/to/your-key.pem
For Windows (RDP)
Use Remote Desktop Connection (
mstsc
).Enter the public IP of your Windows VM.
Log in with the administrator credentials.
2. Installing and Configuring AWS CLI
Install AWS CLI on Linux (Ubuntu/Debian)
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version # Verify installation
Install AWS CLI on Windows (PowerShell)
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
aws --version
Configure AWS CLI
Run the following command and enter your AWS credentials (Access Key ID & Secret Access Key):
aws configure
AWS Access Key ID: Your IAM user’s access key.
AWS Secret Access Key: Your IAM user’s secret key.
Default Region:
us-east-1
(or your preferred region).Default Output Format:
json
(ortext
,yaml
).
You can also manually edit the config file:
nano ~/.aws/config # Linux
notepad C:\Users\USERNAME\.aws\config # Windows
3. AWS CLI Basic Usage
Now that AWS CLI is installed and configured, let’s explore some common commands.
EC2 Instance Management
List all EC2 instances:
aws ec2 describe-instances
Start/Stop an EC2 instance:
aws ec2 start-instances --instance-ids i-1234567890abcdef0 aws ec2 stop-instances --instance-ids i-1234567890abcdef0
Create a new EC2 instance:
aws ec2 run-instances --image-id ami-12345678 --instance-type t2.micro --key-name MyKeyPair
S3 Bucket Operations
List all S3 buckets:
aws s3 ls
Upload a file to S3:
aws s3 cp file.txt s3://my-bucket/
Sync a local folder with S3:
aws s3 sync ./local-folder s3://my-bucket/
IAM User & Policy Management
List IAM users:
aws iam list-users
Create a new IAM user:
aws iam create-user --user-name NewUser
Attach a policy to a user:
aws iam attach-user-policy --user-name NewUser --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess
Lambda Functions
List Lambda functions:
aws lambda list-functions
Invoke a Lambda function:
aws lambda invoke --function-name MyLambdaFunction output.txt
Conclusion
The AWS CLI is an essential tool for managing AWS resources efficiently. With this guide, you’ve learned: ✅ How to log into a VM (Linux/Windows)
✅ Installing and configuring AWS CLI
✅ Basic AWS CLI commands for EC2, S3, IAM, and Lambda
Now you can automate AWS tasks, integrate them into scripts, and manage cloud resources faster!
Next Steps
Explore AWS CLI documentation: AWS CLI Official Docs
Learn advanced scripting with AWS CLI + Bash/PowerShell.
Try AWS CLI v2 for improved performance.
Happy automating! 🚀
#AWSCLI #CloudComputing #DevOps #AWS
Subscribe to my newsletter
Read articles from Sdeep directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sdeep
Sdeep
👋 Hello! I'm passionate about DevOps and I'm proficient in a variety of cutting-edge technologies and always motivated to expand my knowledge and skills. Let's connect and grow together!