Popular AWS CLI Commands Explained with Examples (2026 Updated)

We know that working with AWS CLI can be hard at first. But instead of clicking through dashboards, AWS CLI commands let you manage servers, storage, databases, and serverless functions directly from your terminal, so you can’t ignore it either.

This article makes it easy for you to understand and remember most AWS CLI commands. We will go through each AWS command one by one and explain what they actually do in simple English with examples. We ensure that you don’t just read and forget these AWS CLI commands, but understand and remember them forever.

AWS Commands for Managing EC2 Instances

We use these AWS CLI commands to control the virtual servers that run our applications.

aws ec2 describe-instances

This command lists all the virtual servers in your account. It shows details like the server ID, public address, and current status. We use this to check if our servers are running and to find their network information. It returns a list of data about every server.

Example:

aws ec2 describe-instances

aws ec2 run-instances

This command starts a new virtual server based on a specific template or image. We use the image ID to tell the system what software to install on the new server. The main part is the image ID and the instance type. It creates a brand new server for us to use.

Example:

aws ec2 run-instances --image-id ami-12345678 --count1--instance-type t2.micro

aws ec2 start-instances

We use this command to turn on a server that is currently stopped. It takes the server ID as the main input. This is useful when we want to save money by stopping servers at night and starting them in the morning. The result is a server that changes state to running.

Example:

aws ec2 start-instances --instance-ids i-1234567890abcdef0

aws ec2 stop-instances

This command shuts down a running server gracefully. It requires the ID of the server we want to stop. We use this to stop work on a server without deleting it. The server state changes to stopped.

Example:

aws ec2 stop-instances --instance-ids i-1234567890abcdef0

aws ec2 terminate-instances

This command deletes a server completely. We must provide the instance ID to identify the target. We use this when we no longer need the server and want to stop paying for it. The result is the permanent removal of the server and its resources.

Example:

aws ec2 terminate-instances --instance-ids i-1234567890abcdef0

aws ec2 create-volume

This creates a new storage disk that we can attach to a server. We need to specify the size in gigabytes and the zone where it should live. We use this to add extra storage space to our setup. It returns a new volume ID.

Example:

aws ec2 create-volume --size20--region us-east-1

AWS CLI Commands for S3 Storage

These AWS CLI commands help us store and retrieve files in the cloud.

aws s3 ls

This command lists all the buckets or folders in our S3 storage. We use it to see what containers we have created. It helps us organize and find our files. The output is a simple list of names and creation dates.

Example:

aws s3 ls

aws s3 mb

This makes a new bucket or storage container. The main part is the unique name we give the bucket. We use this to create a new place to store our data. It creates the bucket in the specified region.

Example:

aws s3 mb s3://my-new-bucket-name

aws s3 cp

This command copies files from our computer to the cloud or vice versa. We specify the source file and the destination. We use this to upload website files or download backups. It moves the data between the local machine and S3.

Example:

aws s3 cp myfile.txt s3://my-bucket-name/

aws s3 sync

This synchronizes a local folder with a bucket in the cloud. It looks at both locations and only copies new or changed files. We use this to keep a folder on our laptop exactly the same as a folder in the cloud. It saves time by not copying every file again.

Example:

aws s3 sync ./my-folder s3://my-bucket-name/my-folder

aws s3 rb

This removes a bucket from our account. The bucket must be empty before we run this. We use it to delete storage projects we no longer need. It permanently deletes the container.

Example:

aws s3 rb s3://my-old-bucket-name

aws s3 rm

This deletes specific files from a bucket. We provide the path to the file we want to remove. We use this to clean up unwanted data. The file is gone once we run this.

Example:

aws s3 rm s3://my-bucket-name/unwanted-file.txt

AWS Commands for IAM and Security

We use these AWS CLI commands to control who has access to our cloud resources.

aws iam create-user

This creates a new user identity in our account. We provide a user name for the new person. We use this to give team members access to the console. It returns the user profile details.

Example:

aws iam create-user --user-name NewTeamMember

aws iam create-access-key

This generates a security key for a specific user. We use the user name to tell the system who needs the key. We use this so programs can talk to the cloud without logging in with a browser. It gives us a key ID and a secret key.

Example:

aws iam create-access-key --user-name NewTeamMember

aws iam add-user-to-group

This puts a user into a specific permission group. We need the user name and the group name. We use this to give the user the correct permissions quickly. The user inherits all rules from the group.

Example:

aws iam add-user-to-group --user-name NewTeamMember --group-name Administrators

aws iam list-users

This shows us every user in the account. We use this to audit who has access. It helps us keep track of our team members. It prints a list of all user names and IDs.

Example:

aws iam list-users

aws iam delete-user

This removes a user from the account completely. We must provide the user name to identify them. We use this when someone leaves the team. It deletes their login profile and access keys.

Example:

aws iam delete-user --user-name OldTeamMember

AWS Commands for RDS Databases

These AWS CLI commands manage the cloud databases that store our application data.

aws rds describe-db-instances

This lists all the database servers running in our account. It shows the status, engine type, and endpoint address. We use this to check if our databases are healthy. It gives us a full report on each database.

Example:

aws rds describe-db-instances

aws rds create-db-instance

This creates a new database server. We must specify a unique ID, the engine like MySQL, and the size. We use this to set up a new database for our app. It creates a managed database service for us.

Example:

aws rds create-db-instance --db-instance-identifier mydb --engine mysql --master-username admin --master-user-password password123 --allocated-storage20--db-instance-class db.t2.micro

aws rds start-db-instance

This starts a database that is currently stopped. We provide the ID of the database. We use this to resume work on a stopped database to save costs. The database state changes to available.

Example:

aws rds start-db-instance --db-instance-identifier mydb

aws rds stop-db-instance

This stops the database server but keeps the data saved. We need the database ID to proceed. We use this for development databases that we do not need running all the time. It pauses the billing for compute usage.

Example:

aws rds stop-db-instance --db-instance-identifier mydb

aws rds delete-db-instance

This deletes the database server and the underlying storage. We must provide the ID and a flag to confirm we want to keep a final snapshot. We use this when we are absolutely done with a database. It removes the database from the cloud.

Example:

aws rds delete-db-instance --db-instance-identifier mydb --skip-final-snapshot

AWS Commands for Lambda Functions

We use these AWS CLI commands to manage serverless code functions.

aws lambda list-functions

This shows all the serverless functions in our account. We use it to see what code we have deployed. It helps us find function names and versions. It returns a list of all our functions.

Example:

aws lambda list-functions

aws lambda create-function

This deploys a new function from a zip file. We need to provide the function name, runtime environment, and the role it uses. We use this to upload our code to the cloud. It creates a new endpoint for our code.

Example:

aws lambda create-function --function-name my-function --runtime python3.9 --role arn:aws:iam::123456789012:role/my-role --handler index.handler --zip-file fileb://function.zip

aws lambda invoke

This runs a specific function and captures the result. We provide the function name and the file where we want to save the output. We use this to test our code or trigger it from a script. It executes the code in the cloud.

Example:

aws lambda invoke --function-name my-function response.json

aws lambda delete-function

This removes a function from the account. We must provide the function name. We use this to clean up old code we no longer use. It deletes the function configuration and code.

Example:

aws lambda delete-function --function-name my-function

Getting Started with AWS SDK and Node.js

Once you are comfortable using AWS CLI, the next step is interacting with AWS services programmatically:

Getting Started with AWS SDK and Node.js

This guide shows how to use AWS services directly from Node.js applications using the AWS SDK.

Conclusion

You just mastered the most important tools for managing cloud infrastructure. Learning these AWS CLI commands and understanding the meaning behind them will make you a more efficient and capable developer. Keep this guide handy and practice these commands regularly. The cloud is a powerful place, and mastering these AWS CLI commands opens up endless possibilities for us.

Resources and References:

  • AWS CLI Command Reference The official documentation covering all AWS CLI commands, options, and usage examples across AWS services.
  • Amazon EC2 Documentation The complete guide to launching, managing, and monitoring virtual servers on AWS using the console and AWS CLI.
  • Amazon S3 Documentation Official documentation for AWS object storage, including buckets, permissions, lifecycle rules, and data management.
  • AWS Lambda Documentation The official guide for building, deploying, and managing serverless functions on AWS.
Aditya Gupta
Aditya Gupta
Articles: 479
Review Your Cart
0
Add Coupon Code
Subtotal