The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services from a terminal.
Installation
# Linux (official installer — recommended for all distros)
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# macOS
brew install awscli
# Verify installation
aws --versionConfiguration
aws configure # Set Access Key, Secret Key, Region, and Output format
aws configure list # Show current configuration values
aws configure --profile dev # Configure a named profile (for multiple accounts)
aws sts get-caller-identity # Verify who you are authenticated asS3 (Simple Storage Service)
aws s3 ls # List all buckets
aws s3 ls s3://my-bucket # List contents of a bucket
aws s3 ls s3://my-bucket --recursive # List all objects recursively
aws s3 mb s3://new-bucket # Create a new bucket
aws s3 rb s3://old-bucket --force # Delete a bucket and all its contents
aws s3 cp file.txt s3://my-bucket/ # Upload a file
aws s3 cp s3://my-bucket/file.txt . # Download a file
aws s3 sync ./local-dir s3://my-bucket/ # Sync a directory to S3
aws s3 sync s3://my-bucket/ ./local-dir # Sync S3 to a local directory
aws s3 rm s3://my-bucket/file.txt # Delete a single file
aws s3 rm s3://my-bucket/ --recursive # Delete all files in a bucketEC2 (Elastic Compute Cloud)
# List all instances (formatted table)
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceId, State.Name, PublicIpAddress, InstanceType]" \
--output table
# Start, stop, and terminate instances
aws ec2 start-instances --instance-ids i-1234567890abcdef0
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0
# List security groups
aws ec2 describe-security-groups --output table
# List available AMIs (filtered by name)
aws ec2 describe-images --owners amazon --filters "Name=name,Values=amzn2-ami-hvm-*" --query "Images | sort_by(@, &CreationDate) | [-1]"IAM (Identity and Access Management)
aws iam list-users # List all IAM users
aws iam create-user --user-name john # Create a new user
aws iam delete-user --user-name john # Delete a user
aws iam list-access-keys --user-name john # List access keys for a user
aws iam list-attached-user-policies --user-name john # List user's policiesLambda
aws lambda list-functions # List all Lambda functions
aws lambda invoke --function-name myFunction output.json # Invoke a function
aws lambda get-function --function-name myFunction # Get function detailsRoute 53 (DNS)
aws route53 list-hosted-zones # List all hosted zones
aws route53 list-resource-record-sets --hosted-zone-id Z1234567890 # List DNS recordsCloudFormation
aws cloudformation list-stacks # List all stacks
aws cloudformation describe-stacks --stack-name mystack # Show stack details
aws cloudformation create-stack --stack-name mystack --template-body file://template.yaml
aws cloudformation delete-stack --stack-name mystackSTS (Security Token Service)
# Assume a role (returns temporary credentials)
aws sts assume-role --role-arn arn:aws:iam::123456789012:role/MyRole --role-session-name mysession
# Get the current caller identity
aws sts get-caller-identityProfiles and Regions
Override defaults on a per-command basis.
aws s3 ls --profile dev # Use a named profile
aws ec2 describe-instances --region eu-west-1 # Use a specific region
export AWS_PROFILE=dev # Set default profile for the session
export AWS_DEFAULT_REGION=us-west-2 # Set default region for the session