A collection of cli commands for Shell / PowerShell users
aws events list-rules --query 'Rules[].Name'
# lists AWS CloudWatch event rules.
aws logs describe-log-streams `
--log-group-name /aws/lambda/log-group `
--order-by LastEventTime `
--descending
# lists the log streams and filter results by log group name
aws logs get-log-events `
--log-group-name /ecs/ecs-task-definition `
--log-stream-name ecs/ecs-container-definition/
# lists all events under a stream
aws cloudwatch get-dashboard `
--dashboard-name <dashboard-name>" `
--output text
# displays the details of the specified dashboard
# returns the results in text format instead of JSON
aws cloudwatch list-metrics --namespace <"metric-namespace">
# lists the specified metrics filtered by namespace
aws cloudformation delete-stack --stack-name <stack-name>
# deletes the specified cloudformation stack
aws cloudformation list-stacks `
--stack-status-filter UPDATE_COMPLETE `
--query 'StackSummaries[?StackName==`<stack-name>`].StackId'
# lists all stacks under UPDATE_COMPLETE status and
# filter the results by StackName
aws cloudformation delete-stack --stack-name <stack-name>
# deletes the specified stack
$Env:AWS_PROFILE="<aws-profile-name>"
# sets AWS_PROFILE environment variable on Windows.
echo $Env:AWS_PROFILE
# outputs the value of AWS_PROFILE environment variable on Windows
# use this to confirm environment variable has been set
Remove-Item env:AWS_PROFILE
# removes AWS_PROFILE environment variable from the current session on Windows
export AWS_PROFILE=<aws-profile-name>
# sets AWS_PROFILE environment variable on Linux, macOS, or Unix.
aws configure list
# outputs the value of AWS_PROFILE environment variable on Linux, macOS, or Unix
# use this to confirm environment variable has been set
aws dynamodb create-table `
--table-name <table-name> `
--attribute-definitions AttributeName=Id,AttributeType=N `
--key-schema AttributeName=Id,KeyType=HASH `
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 `
--endpoint-url http://localhost:8000
# creates a new table
aws dynamodb create-table `
--table-name <table-name> `
--attribute-definitions AttributeName=Id,AttributeType=N AttributeName=IsActive,AttributeType=S `
--key-schema AttributeName=Id,KeyType=HASH `
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 `
--global-secondary-indexes IndexName=IsActive_Index,KeySchema=["{AttributeName=IsActive,KeyType=HASH}"],Projection="{ProjectionType=INCLUDE,NonKeyAttributes=["Name"]}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}" `
--endpoint-url http://localhost:8000
# creates a new table along with a global secondary index
aws dynamodb batch-write-item `
--request-items file://<json-file-path> `
--endpoint-url http://localhost:8000
# reads one or more items from json file and writes them to the table.
aws dynamodb put-item `
--table-name <table-name> `
--item file://<json-file-path> `
--return-consumed-capacity TOTAL `
--endpoint-url http://localhost:8000
# creates a new item, or replaces an old item with a new item if another item with the same primary key already exists.
aws dynamodb list-tables --endpoint-url http://localhost:8000
# returns an array of table names associated with the current account and endpoint
aws dynamodb describe-table `
--table-name <table-name> `
--endpoint-url http://localhost:8000
# returns information about the table, including the current status of the table, when it was created, the primary key schema, and any indexes on the table.
aws dynamodb delete-table `
--table-name <table-name> `
--endpoint-url http://localhost:8000
# deletes a table and all of its items
aws dynamodb scan `
--table-name <table-name> `
--endpoint-url http://localhost:8000
# returns all rows from the table associated with the current endpoint
aws lambda list-functions --query 'Functions[].FunctionName'
# list Lambda functions and return their function names
# --query parameter accepts strings that are compliant with the JMESPath specification.
aws lambda list-functions --profile <aws-profile-name>
# returns the list of lambda functions along with their environment variables
aws ecr create-repository --repository-name <repository-name>
# creates an ecr repository
aws ecr get-login --no-include-email
# returns a docker login command along with a token
aws ecr describe-repositories --repository-name <repository-name>
# describes the specified image repositories in a registry
aws ecs list-tasks `
--cluster <cluster-name> `
--desired-status RUNNING
# returns a list of tasks for the specified cluster
# and under specified status
aws ecs describe-tasks `
--tasks <task-id | task-arn> `
--cluster <short-name | full-arn>
# describes a specified task or tasks in the specified cluster
aws rds describe-db-instances --db-instance-identifier <db-identifier>
# Returns information about provisioned RDS instances
aws s3api head-bucket --bucket <bucket-name>
# determines if a bucket exists and we have permission to access it
aws s3api get-bucket-encryption --bucket <bucket-name>
# returns the server-side encryption configuration of a bucket.
aws s3 cp s3://<bucket-name>/sample-video.mp4 c:\sample-video.mp4
# copies a local file or S3 object to another location locally or in S3.
aws s3 ls <bucket-name>
# lists S3 objects and common prefixes under a prefix or all S3 buckets
aws s3 rm s3://<bucket-name> --recursive
# removes all objects from the specified bucket without specifying a prefix
aws secretsmanager list-secrets `
--query 'SecretList[?Name==`<secret-name>`].Name'
# lists all the secrets that are stored by Secrets Manager in the AWS account
# and returns the Name property of the one with the name secret-name
aws stepfunctions list-executions `
--state-machine-arn <state-machine-arn> `
--query 'executions[0]'
# lists the executions of a state machine
aws stepfunctions get-execution-history `
--execution-arn <execution-arn>
# returns the history of the specified execution as a list of events
aws cognito-idp list-user-pools `
--max-results 20 `
--query 'UserPools[?Name==`<user-pool-name>`].Id' `
--profile <>
# lists the names of user pools associated with specified AWS profile
aws cognito-idp delete-user-pool --user-pool-id=<user-pool-id>
# deletes the specified AWS Cognito user pool
aws cognito-idp list-users --user-pool-id <lists users under a pool>
# lists users in the specified AWS Cognito user pool
dotnet lambda package `
--configuration Release `
--output-package ./file.zip `
--framework netcoreapp2.1
# creates package file for the specified configuration
docker build --no-cache -f ./Dockerfile -t my-media/dotnet:2.1-sdk ./
# builds a docker image from docker file and tag the image
docker build ` --build-arg awsAccessKeyId=value ` --build-arg awsSecretKey=value ` --build-arg region=value ` --no-cache ` -f ./Dockerfile ./
# passes arguments to docker build command. # NOTE: trailing backtick'
in PowerShell allows splitting up a command over multiple lines. # Replace backtick with backslash\
if using shell.
docker run -t <image-id>|<repository-name>
# runs a docker container from an image id or repository name
docker run -i -t <image-id>
# helps get inside the docker container by image id
docker run -i -t --entrypoint='bash' <image-id>
# starts a container and stops at bash
docker run `
-e AWS_ACCESS_KEY_ID=value `
-e AWS_SECRET_KEY=value `
-it `
<image-id>
# starts a container and sets environment variables
docker images -f “dangling=true” -q
# shows all the dangling images (untagged images)
docker image prune
# deletes any unused or dangling images
# a dangling image is the one that is not tagged and not referenced by any container
docker ps
# lists all running containers
docker ps -a
# lists all containers including stopped/exited ones
docker stop $(docker ps -a -q)
# stops all docker containers
docker start <container-id>
# starts a stopped container
docker rm -f <container-id>
# stops the container if running and removes it
docker rm $(docker ps -a -q)
# removes all stopped containers
docker exec -it <container-id> bash
# helps get into a running container
docker tag <image-id> xxxxxxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/xx-xxxxx/dotnet:2.1-sdk
# tags a local docker image
docker push xxxxxxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/xx-xxxxx/dotnet
# pushes the docker image tagged in the above command
docker cp <container-id>:/tmp/workdir/file.mp4 ./file.mp4
# copies the file from a running or stopped docker container to host
docker cp ./file.mp4 <container-id>:/tmp/workdir/file.mp4
# copies file from host machine into a folder on running docker container
Ctrl+p, Ctrl+q
# detaches user from docker container but will keep the container running in daemon mode
docker pull xxxxxxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/ffmpeg-container:12
# pulls an image from aws ecr by repository uri
git add -f {file-path}
# stages files before committing
git add -A
# stages all changes
git add .
# stages additions and modifications, but not deletions
git add -u
# stages modifications and deletions, but not additions
git branch --list
# to list all branches in the current repo
git branch -d task/task-99-description
# deletes the local branch
git branch
# lists branches (the asterisk denotes the current branch)
git config mergetool.kdiff3.path="C:/Program Files/KDiff3/kdiff3.exe"
# configures kdiff3 as the default merge tool
git config --list
# shows git configuration including configured diff and merge tools
git commit --amend
# edits a message of the last commit
git commit -m "my message"
# commits changes with a message
git checkout develop
# switches to develop branch
git checkout -b task/task-99-description develop
# creates a new branch off develop and switches to it
git checkout -- .
# discards all unstaged files in the current working directory
git checkout -- src/myfile.txt
# discards changes to a file
git clean -n
# prints out the list of files which will be removed
git clean -f
# deletes untracked files from the repository
git diff --stat --cached origin/task/task-99/description
# compares the differences against remote branch
git fetch --prune origin
# fetches all branches that exist in the origin
# --prune = deletes the remote tracking references
git pull origin develop
# pulls latest from origin/develop branch
git log --pretty=%P -n 1 <commit-number>
# finds the parent of a commit by commit id
git merge develop
# merges develop branch into the current branch
git push -u origin <local-branch>
# pushes local-branch to origin and adds tracking reference
git push --dry-run
# shows what is about to be pushed
1. git rebase --interactive <xxxxxxxx^>
2. git commit --amend (change pick to edit in the line whose commit being modified)
3. git rebase --continue
# allows to change the message of a commit which is not the very latest
# xxxxxxxx^ = number of the commit being edited
git status
# shows the working tree status
git stash list
# lists the stash entries that we currently have
git stash push -m "task-99-description"
# stashes the working copy
git stash apply stash@{0}
# applies the specific stash by stash name
git reset --hard HEAD
# let's you start over the merge if you screwed it up
git reset --hard <your commit hash key>
# let's you reset your repo back a specified commit
# use git log to get the hash key of your desired commit
yarn prettier --write .\file.js
# formats a file using prettier node module
id -u <user-name>
# gets the id of the user by username
find . -iname "*msbuild*"
# starts a case-insensitive (-i) search for keyword msbuild
# in current directory and all directories inside it
cut -d: -f1 /etc/passwd
# lists all local users
adduser <user-name>
# creates a new user
su -c "/usr/share/dotnet/dotnet-sonarscanner end" \
-s /bin/sh <user-name>
# runs dotnet-sonarscanner utility as another user
apt-get install ttf-mscorefonts-installer -y
# installs ttf-mscorefonts-installer
# -y = automatic yes to prompts
curl `
-X GET "http://captive.apple.com/" `
-H "Origin: https://subdomain.mydomain.com" `
-H "accept: application/json"
# helps test CORS
yarn sls deploy `
--aws-profile <aws-profile-name> `
--stage dev `
--region ap-southeast-2
--verbose
# deploys the serverless application to specified region and stage
yarn sls remove `
--stage dev `
--region ap-southeast-2 `
--verbose
# removes the deployed service, defined in your current working directory
1. netstat -ano | findstr :3000
2. taskkill /pid <process-id> /F
# finds the id of the process listening on the specified port and kills it
# /F forcefully terminates the process