Skip to content

Instantly share code, notes, and snippets.

View tpowellcio's full-sized avatar

Troy Powell tpowellcio

View GitHub Profile

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
@tpowellcio
tpowellcio / 2bkp.sh
Created May 24, 2016 12:42
ESXi Backup VMs
#!/bin/sh
SOURCE=$1/*
TARGET=$2
if [ $# != 2 ]; then
echo "Usage: $(basename $0) <SOURCE VM PATH> <DESTINATION PATH>"
echo "Example: $(basename $0) /vmfs/volumes/datastore1/VM1 /vmfs/volumes/datastore2"
exit
fi
@tpowellcio
tpowellcio / vm_bkp.sh
Created May 24, 2016 12:45
Backup VMs using OVFTool
#!/bin/bash
SOURCE=$1/*
TARGET=/Volumes/VMBackup/$2
echo "*** source=$SOURCE"
echo "*** target=$TARGET"
OVFTOOL="/Applications/VMware\ Fusion.app/Contents/Library/VMware\ OVF\ Tool/ovftool"
if [ $# != 2 ]; then
echo "Usage: $(basename $0) <SOURCE VM PATH> <DESTINATION PATH>"
@tpowellcio
tpowellcio / automateUSBscript-on-insert.md
Last active May 24, 2016 14:35
Automatically Clone Files to USB upon insert

#Automate USB Duplication Script on plug in ref:http://ubuntuforums.org/archive/index.php/t-502864.html

This explains how you could run a script made by you (say /usr/local/my_script) when you plug a specific USB device.

  1. First run lsusb to identify your device. Example:
$lsusb
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 040a:0576 Kodak Co.
@tpowellcio
tpowellcio / converting_using_openss.md
Created May 24, 2016 12:47
These commands allow you to convert certificates and keys to different formats to make them compatible with specific types of servers or software. For example, you can convert a normal PEM file that would work with Apache to a PFX (PKCS#12) file and use it with Tomcat or IIS. Use our SSL Converter to convert certificates without messing with Ope…

#Converting Using OpenSSL

These commands allow you to convert certificates and keys to different formats to make them compatible with specific types of servers or software. For example, you can convert a normal PEM file that would work with Apache to a PFX (PKCS#12) file and use it with Tomcat or IIS. Use our SSL Converter to convert certificates without messing with OpenSSL.

##Convert a DER file (.crt .cer .der) to PEM openssl x509 -inform der -in certificate.cer -out certificate.pem ##Convert a PEM file to DER openssl x509 -outform der -in certificate.pem -out certificate.der ##Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes

@tpowellcio
tpowellcio / copyFilesToUSB.md
Created May 24, 2016 12:48
Copy files to USB sticks and unmount

#Copy files to USB sticks and unmount

##Mac copy2usb.sh

#!/bin/bash

DEVICES=/Volumes/U*
for device in $DEVICES
@tpowellcio
tpowellcio / group_user_mod_cmds.md
Created May 24, 2016 12:49
Cleaning up users on linux machine, inconsistent user ids

#Cleaning up users on linux machine, inconsistent user ids

    $ getent group | grep 1063 (grep information for groupid 1063)
    $ getent passwd | grep 1063 (grep information for uid 1063)
    $ usermod -u <userid> <username> (change the user id for username)
    $ groupmod -n <new name> <old name> (change group name to <new name> from <old name>)
    $ usermod -g <group id> <user name> (change the <group id> of <user name>)
    $ groupmod -g <group id> <group name> (change <group id> of <group name>)
    $ id <user name> (get the information for <user name>)
@tpowellcio
tpowellcio / prevent_mac_from_writing_supid_files_to_usb.md
Created May 24, 2016 12:51
Prevent Mac from Writing stupid files to USB

#Prevent Mac from Writing stupid files to USB

mdutil -i off /Volumes/yourUSBstick
cd /Volumes/yourUSBstick
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
cd -
@tpowellcio
tpowellcio / software_raid_5.md
Created May 24, 2016 14:29
Setup Software Raid 5

#Software Raid

  • Installed 4 - 4TB drives onto hagrid using the motherboard SATA ports
    • Set drives to software raid 5 and initialising
  • RAID-5 has become extremely popular among Internet and e-commerce companies because it allows administrators to achieve a safe level of fault-tolerance without sacrificing the tremendous amount of disk space necessary in a RAID-1 configuration or suffering the bottleneck inherent in RAID-4. RAID-5 is especially useful in production environments where data is replicated across multiple servers, shifting the internal need for disk redundancy partially away from a single machine. RAID level 5 can replace a failed drive with a new drive without user intervention. This functionality, known as Hot-spares. Also supports Hot-Swap, Hot-swap is the ability to removed a failed drive from a running system so that it can be replaced with a new working drive. This means drive replacement can occur without a reboot. Hot-swap is useful in two situations. First, you might n
@tpowellcio
tpowellcio / ssl_certs.md
Created May 24, 2016 14:30
Creating SSL Certs

#Creating Certificates Reference

  1. From a terminal:
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  1. Enter the requested information:
  2. Common Name: The fully-qualified domain name, or URL, you're securing. If you are requesting a Wildcard certificate, add an asterisk (*) to the left of the common name where you want the wildcard, for example *.coolexample.com.
  3. Organization: The legally-registered name for your business. If you are enrolling as an individual, enter the certificate requestor's name.