• Useful commands to run in a terminal

    With the 1000’s of commands used over the years I sometimes forget what I have run. This post is a collection of commands that have been useful for me in the past and might be useful to others too. All commands are set to run from local(.).

    CREATE AN SSH TUNNEL (remember -i if using pem):

    ssh -C2qTnN -D 8080 user@location


    find . -type d -perm 0XXX -exec sudo chmod XXX {} \;


    find . -type f -perm 0XXX -exec sudo chmod XXX {} \;

    Read the rest of this entry »

  • Reverse Proxy from IIS Website to WordPress

    Our client has a corporate site at www.domain.com hosted on IIS and the blog hosted on a subdomain on a separate LAMP server at blog.domain.com. Our client feels serving their blog up under www.domain.com/blog will help their SEO and they will rank better (this is debateable but what client wants is what they will get).

    The objective of this project is to serve a wordpress site on a linux server under a subdirectory on IIS. In order to accomplish this we need to setup IIS to act as a reverse proxy, thus serving the the wordpress site under the desired blog subdirectory.

    The first step is to make sure your version of IIS is compatible (IIS 7+). Once you have determined this, you will need to install the Application Request Routing Module. The easiest way to go about installing these is using the

    Read the rest of this entry »

  • 301 redirect all subdomains to new domain on apache

    While trying to consolidate many subdomains under one new domain on apache we had to add the following into the sites configuration file to redirect the multiple subdomains to one. This could be added into the .htaccess as well.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^newdomain.com$ [NC]
    RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]

    Read the rest of this entry »

  • Merging 100+K Gzipped Files Together

    In order to open a large volume of cloudfront logs in a spreadsheet, we needed to merge over 100K .gz files on OS X Maverick into a single file. Trying to use the following command resulted in a /usr/bin/cat: Argument list too long error:

    cat logs/*.gz >> combined_logs.gz 

    The reason this error occurs is because bash expands the asterisk to all matching files, producing a very long command line. To circumvent this problem the xargs command needs to be used to split up the list:

    Read the rest of this entry »

  • Simple Bash Automation for EC2 Instance Backups using Cron on a Mac Mini

    The problem that needed to be solved was to have a simple backup system that could be used to maintain a bunch of EBS backed Windows instances on AWS. We wanted to keep a weeks worth of backups, always discarding the older AMI’s. A local mac mini was used to run the necessary scripts and cron. We didn’t want just EBS snapshots, we wanted a full AMI everyday. There are other solutions if you just want to backup an EBS drive on a schedule, and even for this but this one suits our needs.

    Read the rest of this entry »