How to password protect a zip file in Mac OSX

For some reason there is no way (as of the date of this writing) to right click, zip and password protect a file in OSX. So we have to go to the Terminal app, or my preference - iTerm2.

I like to launch pretty much everything in OSX by using the shortcut/hotkey: Command + Space bar. This will open the Spotlight Search bar for you. Type “Terminal” in Spotlight, then double-click on Terminal (or select it and press the enter key) to open it. Alternatively, you can go to Finder, scroll down to “Utilities,” and then select “Terminal” from the Utilities programs folder.

In the Terminal window you'll have to navigate to the location of the file you want to zip. Once there type:

zip –e name_of_zip_file_to_create name_of_file_to_zip
  • The “-e” flag means create an encrypted zip file.
  • The first file name is what you want the zipped file to be called.
  • The second file name is the folder or file you want to zip.

Example

Erics-MBP:~ ewilson$ cd Desktop/
Erics-MBP:Desktop ewilson$ zip -e wilson.zip wilson.pdf
Enter password:
Verify password:
adding: wilson.pdf (deflated 4%)

As you can see the archive utility will ask you to enter a password twice. Complete this step and you'll have successfully password protected you zip file.

How to shut down VirtualBox / Vagrant from CLI

So you need to stop one or more running VirtualBox instances that you may have started and are hanging around. Here are a few helpful commands:

List all running machines (returns name and UUID)
VBoxManage list runningvms

Stop running VMs by "hibernating" them (recommended to avoid data loss)
VBoxManage controlvm <name|uuid> savestate

Poweroff running VMs (not recommended because we may lose data in the guest)
VBoxManage controlvm <name|uuid> poweroff

Use ACPI in an ACPI-aware guest OS (preferable to poweroff for graceful shutdown of guests)
VBoxManage controlv m <name|uuid> acpipowerbutton

How to repair Homebrew after OS X upgrade

I was getting the following error when running brew after the latest upgrade to OS X (El Capitan).

 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory

I couldn't even run brew update - arg.

This is what I did to correct the issue - git to the rescue!

cd /usr/local/Library

git pull origin master

git pull will throw an error if you have changes in the directory (/usr/local/Library). If so, you'll have to fetch the master branch and perform a hard reset.

git fetch --all

git reset --hard origin/master

You should be able to now use brew again - hurrah!

Note: in the event you installed Homebrew as a non-root user, you'll need to cd to /Users/non-root-user-rname/homebrew/Library instead of /usr/local/Library.