How to Encrypt a File or Folder in OSX

You need to email a file or folder of files to someone, but the information is sensitive. These slightly geeky but easy to follow instructions will show you how to do it.

We’re going to compress the file(s) into a single zip file that’s encrypted by issuing one single command into the Terminal.

When you email the zipped file to a Mac or Windows user, all they will have to do is double click the file and enter the password you used to encrypt the file. Please after doing this do NOT put the password in the body of the email! Call them, text them, direct tweet them, just don’t put it in the email.

One File One Folder


For this example, we’ll start with a text document entitled bob.rtf and a folder is called bob_folder. Ready?

Open Terminal


Launch the Terminal, located inside Applications/Utilities.



Print Working Directory


Type pwd to print the working directory which will tell us where in the directory structure Terminal opened. In the image above, it shows I’m in my user directory allison on the hard drive fatso. I have a bit of a non-standard setup, you should see /Users/yourusername. If you don’t, type

    cd ~

which means change directory to my user home directory.

Change Directory to Desktop


By typing

    cd Desktop

we have moved down into the desktop folder. Note that Desktop must start with a capital D.

List Files


If you type

    ls -l

you’ll get a listing of all the files on your desktop. I do this just to ensure that I know I’m in the right place and to be sure the files are there. If you’re like most people you might have a lot of files on your desktop, but just look to make sure the file and/or folder you want to encrypt is there.

And Now to Zip

  1. All the heavy lifting is over. Simply type:
    zip -e bob.rtf

That zips bob.rtf up, encrypts it, and makes it into
2. Now Terminal will ask you (twice) for the password to UNencrypt the file <– Remember this password!
3. Let’s verify the file was created by typing

    ls -l

4. As you can see we now have bob.rtf AND



In the Finder, double click on and it should launch the Archive Utility built into OSX and then prompt you for a password to open the file.

Bonus Tip – Zip and Encrypt a Folder


You only have to add two characters /* to the command to encrypt a folder. This time our folder is called bob_folder so the command is:

    zip -e bob_folder/*

If you have folders within that folder, be sure to add -r to the command to recursively archive the folder:

    zip -er bob_folder/*

As you can see above you’ll be prompted twice for the password to encrypt the file and then you’re done! Just as before, a Windows or Mac user can double click this encrypted zip file and it will delightful expand into a nice folder when the password is entered.

Final Word

Just in case you missed it the first time, please after going to this much care do NOT put the password to unencrypt the file into the email itself! Call the person, text, them, carrier pigeon if you have to, just don’t put the two things together!

3 thoughts on “How to Encrypt a File or Folder in OSX

  1. […] How to Encrypt a File or Folder in OSX […]

Leave a Reply

Your email address will not be published.

Scroll to top