Introduction To AWS Commands
AWS commands are the CLI commands which are used in the Amazon web service command-line interface to perform certain operations. With CLI commands one can manage the amazon services to configure and control it. One can write a script to automate certain operations to avoid repetitive tasks. AWS CLI is very simple and well laid which makes it easy to use over time, it provides better speed and there are several good functionalities. AWS CLI is an open-source interface with which you can interact with any AWS service using your local command shell. According to the choice of your operating system, there would be slight variances in the commands to be used in CLI. You can use remote terminals such as SSH or PuTTY or AWS System Manager.
What Are Basic AWS Commands?
Below are some basic commands which can be used to perform basic operations:
1. Install Amazon CLI.
Code:
sudo apt-get install –y python-dev python-pip
sudo pip install awscli
aws configure
2. The command for checking the output from the file.
Code:
cat <file>
3. In case you want to print a specific column per line, the command for printing the 3rd column is.
Code:
cut –f 3
4. The command for sorting the data.
Code:
sort
5. Use the below commands to print the first few lines and last few lines [let’s say 3] respectively.
Code:
head –n 3 & tail –n 3
6. The command for listing all trails.
Code:
aws cloudtrail describe –trails
7. The command for listing the names of all trails.
Code:
aws cloudtrail describe –trails –output text | cut –f 8
8. Command to delete the trail is.
Code:
aws cloudtrail delete –trail
What Are The Intermediate AWS Commands?
Below are some of the intermediate commands:
1. A command to add a tag to the trail.
Code:
awscliaws cloudtrail add–tags
--resource-id awslog
--tags-list “key=log-type, value = all”
2. Command to list all tags from trail associated to specific resource.
Code:
aws cloudtrail list–tags --resource-id-list
3. Command to remove the tag.
Code:
awscliaws cloudtrail remove–tags
--resource-id awslog
--tags-list “key=log-type, value = all”
4. The command to list info of all users and to create a new user.
Code:
aws iam list-users
new user: aws iam create-user
--user-name aws-admin1
5. Command to create multiple users from a file.
Code:
allUsers=$ (cat ./user-names.txt)
for username in $allUsers; do
aws iam create-user
--user-name $userName
Done
6. Command to delete multiple users from a file.
Code:
allUsers=$ (cat ./user-names.txt)
for username in $allUsers; do
aws iam delete-user
--user-name $userName
Done
7. Command to list the password policy.
Code:
aws iam get-account-password-policy
8. Command to delete the password policy.
Code:
aws iam delete-account-password-policy
What Are Advanced AWS Commands?
Below are some advanced commands.
1. Command to get the list of last access time for the access key.
Code:
aws iam get-access-key-last-used
--access-key-id ASDKLFJ654EXAMPLE
2. Command to deactivate access key.
Code:
aws iam update-access-key
--access-key-id ASDKLFJ654EXAMPLE
--status Inactive
--user-name aws-admin1
3. Command to delete access key.
Code:
aws iam delete-access-key
--access-key-id ASDKLFJ654EXAMPLE
--status Inactive
--user-name aws-admin1
4. Command to create an instance.
Code:
aws ec2 run-instances
--image-id ami-f0e7d19a
--instance-type t2.micro
--security-group-ids sg-00000000
--dry-run
5. Command to create log stream.
Code:
aws logs create-log-stream
--log-group-name “DefaultGroup”
--log-stream-name “syslog”
6. Command to delete the log stream.
Code:
aws logs delete-log-stream
--log-group-name “DefaultGroup”
--log-stream-name “Default Stream”
Conclusion
The Amazon CLI is a tool to manage AWS services. With CLI the user can control multiple services by using some commands and also has the liberty to create a script to automate the repetitive tasks. In this article, we have seen some basic, intermediate and advanced commands.
Recommended Articles
This is a guide to AWS Commands. Here we discuss the introduction and what are basic AWS, intermediate and advanced command? along with examples. You can also go through our other related articles to learn more –
Are you preparing for the entrance exam ?
Join our Cloud Computing test series to get more practice in your preparation
View More