Sunday, February 17, 2013

How change permissions of files and directories using find command

Find is a very powerful tool in linux which is use to search files and than can perform any specific action on them as per required.

To Find the files having specific permission:

# find /tmp/ -type f  -perm 666

> /tmp/ : Its the path of the directory in which you want to search.
> -type f : Here we are searching files only.
> -perm 666 : Searching files having permission 666.

To Find the files having specific name and permission:

# find /tmp/ -type f -name '*.php' -perm 666

> -name '*.php' : Its used to search files with name ending from '.php'.

To exclude any folder from find and change the permission of any specific file:

# find /tmp/ -name "extras" -prune -o -type f -iname '*.cgi' -print -exec chmod 774 {} \;

> -name "extra" -prune -o : It will exclude the "extra" folder from search.
> -iname '*.cgi' : It will search the all files with '.cgi' extension.
> -print : It will print all the files which will be find with '.cgi' extension.
> -exec 774 {}\; : it will change teh permission of all the '.cgi' files found to 774.

To change the permission of all the files and directories under a folder:

# find /tmp/ -type f | xargs chmod 664

> xargs chmod 664 : Changing permission of all the files under /tmp/ to 664

# find . -type d | xargs chmod 755

> xargs chmod 775 : Changing permission of all the directories under /tmp/ to 664 

Friday, February 15, 2013

How to create Amazon web services (AWS) EC2 Instances..

Amazon web services are the most used and the best Cloud computing platform out there in market today. Following is the way to create EC2 (Elastic cloud compute) instance..

Login into your AWS account and go into EC2 under Compute and Networking..

In the EC2 dash board you will find the following screen which has info about all the current running instances, elastic IP's, Load balancers, etc..
To create an Instance click the Launch Insatnce..

After clicking the Launch Instance you will get the following screen..
Classic wizard: It gives you many customization option regarding the instance..
Quick Launch Wizard: It has predefined parameters which is used to get images up and running quickly..
AWS marketplace: Its where you can buy other images rather than the default provided by the Amazon like Centos, Debian, etc

We will be creating the image via Classic wizard..

Here you see the images which are provided by the AWS, star indicates that the images are free to use without any additional charges..
My AMIs: If you have created your own image than that will be available here to use.
Community AMIs: These are images which are created by people and can be used by any body at certain price get by the owner.

 I am selecting here Ubuntu 12.04 64-bit..

By Number of Instances you can decide how many instances you wanna launch of configuration we will be configuring.
Instance Type is what type of instance you want depending upon cores and RAM..
Launch Instance is where we decide where we want our image in EC2 or VPN which we can set according to our need.

Star indicates that this instance can be used for free and rest are defined according to there computing powers, select which one fulfills your needs, I am selecting the T1 Micro instance.

Availability Zones are use so that in which zone of word you wanna host your images, As i have selected northeast zone there is further classification if i want to give priority to any specific zone in northeast as well..

Request Spot Instances: These  are used in case where you want to bet for a instance at a low price, whenever amazon have a server free it will provide you with that but if in case it get a request than it will terminate your instance and use that computing power for instances which aren't betting at low price..

In following we select the Kernel ID, RAM Disk ID if you wanna use any specific one, i am proceeding with Default..
You can use special Amazon monitoring if you want it costs a bit but can help you maintain your instances better.
User Data: You can fill details about your instance here..
Shutdown Behavior: It help in deciding what you wanna do when you shutdown the image(reboot, terminate, shutdown).

This is used to do disk partitioning according to your need..

Here you can name your instance and give description about it, as i will be using my instance as web server so did naming as such...

Key Pairs is very important in EC2 as it grants you access to your instances, if you have a already existing one can use that or can create new one.

Add the name here by which you wanna create and than download to your local system to login in your system in future..

Firewall configuration is used to set rules for your instance like which port you want to open for services like ssh, apache, etc...
You can use your existing security groups or create new one..

Here we are creating new Security group which i will be using for my we server..
Group name: Name of the group which u wanna create
Group Description: Description about group
Inbound Rules: By default EC2 images have no inbound and all outbound, so we will be setting ports(services) which we wanna give access to our instance..

Here i have added basic web servers ports access to my instance, keep in mind you need to enable ssh also else you will not be able to login in you instance..

These are the details of the instance which will be created just go and Launch..:)

Conformation of launching instance..

Now you will be able to see your instance running in your EC2 dashboard..

To login to your Instance you can use putty in windows but you need to convert your .pem key to ppk so that putty can recognize it,
Dowload the puttygen from so that you can convert it, than  load that file..

Import your key..

saving the new key...

Adde key to your ssh logi by going to SSH under connections than auth and add the key..
Add the public name of the instance to ssh..

For Linux users just use the following command from terminal:
ssh -i path of key ubuntu@public name of instance

Use Ubuntu user to login with key..

Installed the Apache and hosted the site as demo..

Run any web service as you want..;)

Setup fully configurable EFK Elasticsearch Fluentd Kibana setup in Kubernetes

In the following setup, we will be creating a fully configurable Elasticsearch, Flunetd, Kibana setup better known as EKF setup. There is a...