How To Reduce the Size of a PDF Using Ghostscript

Author: , February 4th, 2017

Make sure you have Ghostscript installed, then: 1 gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS="/ebook" -sOutputFile=output.pdf input.pdf gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=”/ebook” -sOutputFile=output.pdf input.pdf -dPDFSETTINGS={value} where {value} is one of: /screen – the lowest resolution and lowest file size, fine for viewing on a screen /ebook – mid-range resolution and file size /printer – high-quality […]

How To Send Email From the Command Line on MacOSX 10.10.5 Yosemite

Author: , January 29th, 2017

I wanted to send email from cron for various reasons, but the emails would bounce with an error 554: 554 5.1.8 : Sender address rejected: Domain not found Clearly, Postfix was using the “internal” hostname of myappledesktop.local (MacOSX has TWO hostnames! also, myappledesktop.local is not the real hostname ;-). So, I needed two things: 1. […]

How To Install a .pkg file from the Command Line on MacOSX

Author: , August 12th, 2016

sudo /usr/sbin/installer -pkg /path/to/yourFile.pkg -target /

How To Create a PDF from Multiple Image Files on the Command Line

Author: , June 6th, 2016

convert myFile*.jpg myFile.pdf convert myFile*.png myFile.pdf

How To Eject a Volume from the Terminal Command Line in MacOSX

Author: , December 8th, 2015

As always, YMMV… 1 2 3 4 5 6 7 8 9 #!/bin/bash # Usage: eject [fullpath to mount point] DISK="${1:-/Volumes/YourUSBFlashDriveName/}" df -h "$DISK" > /dev/null 2>&1 if [ $? -eq 0 ]; then    diskutil unmountDIsk `diskutil list "$DISK" | grep ^/dev/` else    echo Volume $DISK is not mounted…skipping. fi #!/bin/bash # Usage: […]

How To Convert UNIX Timestamps to Date using PHP CLI

Author: , August 15th, 2015

For a quick visual check to see what the human-readable date is based on a UNIX timestamp integer: php -r ‘print date(“r”,1483228799);’ php -r ‘print strtotime(“1 Jan 2015″) – 1;’

How To Add a Column of Numbers Using AWK

Author: , January 1st, 2015

awk ‘{sum+=$1}END{print sum}’ inputFile

How To Show All Files in MacOSX Yosemite via Terminal

Author: , October 29th, 2014

SET THE DEFAULT TO SHOW Run this command in a Terminal window: defaults write com.apple.finder AppleShowAllFiles YES Relaunch Finder: Hold down the Option/ALT key on your keyboard, then right-click the Finder icon in the dock and select Relaunch. SET THE DEFAULT TO HIDE defaults write com.apple.finder AppleShowAllFiles NO then relaunch finder as above.

How To Change The Root Password In MySQL

Author: , October 26th, 2011

Using mysqladmin on the command line If you have never set a root password for MySQL server, the server does not require a password at all for connecting as root. 1 2 $ mysql -u root mysql> $ mysql -u root mysql> To set the root password for the first time, use mysqladmin: 1 $ […]

How To Export WordPress From The Command Line CLI

Author: , July 29th, 2011

Create a file called export.php in the wordpress top directory containing the following (remember to add the PHP tags at the top and bottom): 1 2 3 4 5 6 7 8 9 10 11 include ‘wp-config.php’; include ‘wp-admin/includes/export.php’;   ob_start(); export_wp(); $file = ob_get_contents(); ob_end_clean();   $fh = fopen("wordpress-" . date(’Y-m-d’) . ".xml", ‘w’); […]