Saturday, February 6, 2016

tcpdump to check network traffic

There are many situations when you want to track the events occurring over the network which could come handy during the high traffic. Also it can help you track if the traffic that you receiving is genuine and analyzing the pattern you can take better informed decisions.

tcpdump analyzes the tcp traffic like your webserver traffic which works on the tcp protocol very effectively. You would need the root privilege to see most part of the network due to the security involved.

Following are the handy commands to be used in the tcpdump

1. To see the interfaces on which the tcpdump can listen
tcpdump -D

Creating Logical Volume Manager Partition

!! Steps to create Logical Volume Manager Partition.
1. Check Partition on system using below command
  • #fdisk -l

2. Create Partition
  • #fdisk /dev/sda

a. n Option for create new Partition
b. p Option for preview new Partition
c. w Save Partition
d. q Quit
3. Use the below command to update the kernel
  • #partprobe

Mysql admin tasks in aws

MySQL Administration tasks
  • To start/stop/restart mysql
    • As root/sudo, invoke /etc/init.d/mysqld (start/stop/restart) (i.e. /etc/init.d/mysqld start)
  • To make mysql accessible to outside world
    • Make sure you have a static ip address (like on ec2 instances, use elastic-ip)
    • Edit (as root/sudo) /etc/mysq.cnf and make sure bind-address is (i.e. bind-address=
    • Then restart mysql
  • To give a specific user outside world privilege access
    • For user xyz to xmlloader database do the following
      • GRANT ALL ON xmlloader.* to 'xyz'@'' IDENTIFIED BY '[xyzpassword]'
        • The [xyzpassword] is something you need to set/specified (i.e. it's new)
  • To export full database as sql inserts
    • As root/sudo, invoke mysqldump -u [user] -p[userpassword] [database] > [output file name]
      • i.e. sudo mysqldump -u dbuser -pdbuser feedloader > fl_loader.sql
  • To import full database (i.e. new database) from export script
    • As root/sudo, invoke mysql -u [user] -p[userpassword] [database] < [input file name]
      • mysql -u dbuser -pdbuser feedloader < fl_loader.sql
  • To create/grant user/new users to the database

Best Practices in Lamp Environment

Here you will find a list of standards to reference.
  • Redirect-Only VHost
VHost example
  1 . Use Apache's RewriteRule instead of Redirect
  2 .     example:
  3 .     
  4 .         ServerAdmin [email protected]
  5 .         ServerName site-to-be-redirected.com
  6 .         ServerAlias www.site-to-be-redirected.com
  7 .         ExpiresActive On
  8 .         ExpiresDefault "access plus 1 minute"
  9 .         RewriteEngine On
 10 .         RewriteRule ^/(.*) http://www.othersite.com/path/$1
 11 .         RewriteCond %{REQUEST_METHOD} ^TRACE
 12 .         RewriteRule .* - [F]
 13 .     

Monday, February 1, 2016

Script to Delete AMI and associated Snapshots

While working on the Console, if you are going to deregister the AMI in the Amazon console , it doesn't remove the snapshots associated with that AMI. It will only deregister the AMI after which you won't be able to figure out which all snapshots were left behind.