AWS EC2 CLI - Cheat sheet

Below is the cheat sheet of AWS CLI commands for EC2.
If you are new to EC2, it’s recommended that you go through this free AWS EC2 crash course.
If you want to know how to install AWS CLI please follow steps on this post
Get help
aws ec2 help
Create instance EC2 Classic
aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type t1.micro --key-name MyKeyPair --security-groups my-sg
Create instance in VPC
aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type t2.micro --key-name MyKeyPair --security-group-ids \
sg-xxxxxxxx --subnet-id subnet-xxxxxxxx
Start instance
aws ec2 start-instances --instance-ids <instance-id>
Stop instance
aws ec2 stop-instances --instance-ids <instance-id>
Reboot instance 
aws ec2 reboot-instances --instance-ids <instance-id>
Terminate instance
aws ec2 terminate-instances --instance-ids <instance-id>
View console output
aws ec2 get-console-output --instance-id <instance-id>
Describe Instance
aws ec2 describe-instances --instance-ids <instance-id>
Create an AMI
aws ec2 create-image \ --instance-id <instance-id> \ --name myAMI \ --description 'CloudVedas Test AMI'
List images(AMIs)
aws ec2 describe-images --image-ids <ami-id>
List  security groups
aws ec2 describe-security-groups
Create security group
aws ec2 create-security-group --vpc-id vpc-1234abcd --group-name db-access --description "cloudvedas db access"
Get details of security group
aws ec2 describe-security-groups --group-names <group-name>
Delete Security group
aws ec2 delete-security-group --group-id sg-1234abcd
List key pairs
aws ec2 describe-key-pairs
Create keypair
aws ec2 create-key-pair --key-name <value>
Import keypair
aws ec2 import-key-pair --key-name keyname_test --public-key-material file:///cldvds/sagu/id_rsa.pub
Delete keypair
aws ec2 delete-key-pair --key-name <value>
Check the networking attribute
aws ec2 describe-instance-attribute --instance-id <instance-id> --attribute sriovNetSupport
Add tags to instance
aws ec2 create-tags --resources i-xxxxxxxx --tags Key=Name,Value=MyInstance
Add EBS volume
aws ec2 --block-device-mappings "[{\"DeviceName\":\"/dev/sdf\",\"Ebs\":{\"VolumeSize\":20,\"DeleteOnTermination\":false}}]"
List EBS volumes
aws ec2 describe-volumes
Check snapshot associated with EBS volume
aws ec2 describe-volumes --volume-ids vol-01c6l3de3v21bd46s
Note:- All the above commands are taken from different AWS EC2 CLI reference guides and put in one place over here. Please run the commands after due diligence as we won’t be responsible for any mistakes in executing the commands and it’s consequences.  If you have any concern or query feel free to contact us.

AWS S3 CLI - Cheat sheet

Below is the cheat sheet of AWS CLI commands for S3.
If you are new to S3 it’s recommended that you go through this free AWS S3 crash course.
If you want to know how to install AWS CLI, follow steps on this post.
Get help
aws s3 help
or
aws s3api help
Create bucket
aws s3 mb s3://bucket-name 
Removing bucket
aws s3 rb s3://bucket-name
To remove a non-empty bucket (Extremely careful while running this). This will remove all contents in the bucket including subfolders and data in them.
aws s3 rb s3://bucket-name --force
Copy object
aws s3 cp mypic.png s3://mybucket/
Copy buckets
aws s3 cp myfolder s3://mybucket/myfolder --recursive
(Note: –recursive will copy recursively everything including the subfolders)
Sync buckets
 aws s3 sync <source> <target> [--options]

List buckets
aws s3 ls
List specific bucket
aws s3 ls s3://mybucket
Bucket location
aws s3api get-bucket-location --bucket <bucket-name>
Logging status
aws s3api get-bucket-logging --bucket <bucket-name>
ACL (Access Control List)
The following example copies an object into a bucket. It grants read permissions on the object to everyone and full permissions (read, readacl, and writeacl) to the account associated with user@example.com.
aws s3 cp file.txt s3://my-bucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=emailaddress=user@example.com

Solved : Comparing Run Levels in Linux and Solaris and precautions withthem

Many people get confused between run levels in Linux and Solaris. One major difference among these can be disastrous also.  In this post we will show you the different Run levels in both these OS and what precautions you should take while working on these.
Let’s first take a look at Run levels.
Linux Run Levels
IDNameDescription
0HaltNo activity, System can be safely shut down.
1Single-user modeFor administrative tasks only. Rarely used.
2Multi-user modeMultiple users but no NFS (Network File System).
3Multi-user mode with networkingMultiple user but command line mode only.
4Not used/user-definableFor special purposes. User definable.
5Start the system normally with appropriate display manager (with GUI)It’s similar to run level 3 but with GUI display.
6RebootReboots the system.
Solaris Run levels
IDNameDescription
0Power-down statePower down state(OBP level after POST). Will bring server to OK prompt for maintenance.
s or SSingle-user stateTo run as a single user with all file systems mounted and accessible. Only root user is allowed login.
1Single User – Administrative stateTo access all available file systems with user logins allowed.
2Multi-user modeMultiple users but no NFS(Network File System). i.e. all daemons running except NFS daemon.
3Multi-user mode with networkingAll daemons running including NFS with GUI.
4Not used/user-definableFor special purposes. User definable.
5Power-offShutdown gracefully. Difference from Level 0 is that you won’t get any OBP (OK) prompt in Level 5
6RebootReboots the system.
Precaution
Not sure if you have noticed but there is major difference in Run Level 5 of both the OS. For Linux, run level 5 means multi user with GUI, all good. But for Solaris, run level 5 means power-off, ouch! . Many Linux admins who start working on Solaris makes the mistake of executing “init 5” on Solaris to get the GUI but, that actually brings down a Solaris server. Hope you never make this mistake on production box.
Check current run level
who -r
Above command will tell  you the current level of your system.

How to prepare for AWS Certified Solutions Architect - Professional

Hello!
In this post we will discuss how to prepare for AWS Certified Solutions Architect – Professional certification.
Pre-requisite
Only pre-requisite to appear for the professional exam is that you clear  AWS Certified Solutions Architect – Associate certification.  You can check here about how to prepare for associate certification.
Once you have cleared the associate exam you can start preparation of  AWS Certified Solutions Architect – Professional certification.
Many of the topics in the professional exam are same as that of the associate exam. So in professional exam you may actually see few questions are repeated from associate exam itself.
But still it has a lot of new topics also. Below are the topics on which you can expect most questions in exam.
Exam Topics
  • VPC
  • EC2
  • S3
  • Amazon Elasticache
  • Redshift
  • Cloudfront
  • Elastic Transcoder
  • AWS Data Pipeline
  • RDS
  • Cloudsearch
  • EMR
  • DynamoDB
  • SQS
  • CloudTrail
  • KMS
  • Kinesis
  • Opsworks
  • Auto Scaling
  • ELB
  • VPC peering
  • Direct Connect
  • Cross Account Access
Preparation
As you can see the list above contains a wide range of topics and reading about them can be overwhelming. You can also see the official exam blueprint here . It is good if you have at least 1 year of experience with these AWS technologies.
You can start your preparation by attending AWS  classroom training or you can go for online courses. I personally liked the contents of two online courses one was from acloudguru and  other from linux academy .
Both the courses are good but I chose acloudguru course as the course allowed you lifetime access. While for linux academy you have to pay monthly fee. I knew that with full-time job it may take me more than a month to prepare for this exam so I decided to opt for the acloudguru course.
The acloudguru course is comprehensive and the trainer Ryan covers the topics in a decent way. The course alone is not enough to clear the exam but it will give you a good understanding of the exam topics.
Apart from the course you should also refer to the AWS FAQs  which are very helpful during scenario based questions.
Also Linuxacademy gives you 7 days free trial so you can use that period to do their practice exams which also has lot of good questions.
Exam pattern
  • Multiple choice and multiple answer questions.
  • You will be given scenarios and questions will be based on that. Only few will be direct questions.
  • Exam will be of 170 minutes
  • And you can expect approx 80 questions
Cost
Exam cost is USD 300
You also have an option to appear for practice exam from Amazon. It costs you USD 40. Many people have told me that the actual exam is easier in comparison to the practice exam. So, if you score good in practice exam you can be sure about your preparation.
Sample Questions
You can refer to some sample exam questions here and on Udemy.
Hope the above info is helpful to you. Do let me know if you have any query.
Best of Luck for the exam!

How to change punctured wheel of a car

Before your start replacing the punctured wheel get these things ready.
  • Jack and It’s handle
  • Spanner to unscrew
  • Good wheel (of course!)
Now let’s do it.
Step 1 :- Park the car on a flat ground.
Step 2 :- Put it in first or reverse gear and turn off the car so that it doesn’t move.
Step 3 :- Next step is to remove the wheel cap. Generally the wheel caps are not fixed with screws(check next step if it is fixed with screws). So try to slowly pull out  the cap from different points on cap. There will be one point where the cap will be loose and you can easily pull out the wheel cap from there.
Step 4 :- Some wheel caps may be fixed with the screws of wheel.  To loosen the screws, you will have to unscrew them in anticlockwise direction using a spanner. When you loosen the screws, unscrew the one’s opposite to each other first instead of side-by-side. Don’t remove the screws completely now. It will be done in next steps.
Step 5 :- Take a picture of the wheel which you want to replace. This will help if you have any confusion while putting the good wheel or screws back.
Step 6 :- Fix the jack below the car near the punctured wheel. Refer to the car manual if you don’t know how to use the Jack. Ensure that you don’t put jack below the plastic parts. It should be below the metal body of the car. Lift the car with jack using the jack handle only after you have slightly loosened the screws as the wheel may just keep on rolling if it’s already in air.
Step 7 :- Punctured tire should be in air now, approximately a centimeter above the ground. Once you have loosened and removed all the screws remove the punctured tire. The wheel may be tight so give it some strokes and try to pull it out. Be careful while pulling out  as the wheel can be heavier than you expect.
Step 8 :- Get the good wheel from the back of your car and put it in the place from where you removed the punctured wheel.
Step 9 :- Tighten up the screws just with hands to ensure that the wheel is fitted properly.
Step 10 :- Now wind the jack down to ensure car wheels are resting on ground.
Step 11 :- Tighten the screws with spanner using your hand first and later with foot to ensure its tightened properly.
Congrats you have successfully replaced a punctured wheel. That’s all folks!