Hiding Files and Folders

What are the ways that you can hide files and folders from prying eyes?  But first, ask yourself, are you trying to prevent people from noticing them, or are you trying to prevent people from reading, and accessing the content…

If your goal is to protect the content from unauthorized access, there are at least three methods:

  • Encrypted Disk Images
  • File Vault
  • Whole Disk Encryption (eg. Pointsec, PGP Whole Disk Encryption, etc)

A disk image is a file that appears to be a mounted hard drive, thumb drive, or other type of removable media to the computer.  The most common place to encounter a disk image, is when downloading software for the Macintosh.  The Macintosh DMG is one standard for software distribution.  Encrypted Disk images require a password or token to allow access to the contents of the image.

File Vault is a Encrypted Disk Image on steroids.  It takes the users home directory, packages it on a Disk Image, and then only mounts it when the user logs in.  Usually overkill if you want to prevent someone from examining your pictures, ebooks, etc…  But if you work with confidential data, it could be useful.

Follow these steps to create an encrypted disk image:

  1. Open Disk Utility (/Applications/Utilities/).
  2. Mac OS X 10.4, 10.5 or later: Click the New Image button, or choose New > Blank Disk Image from the Disk Utility File menu.  Mac OS X 10.3 through 10.3.9: Choose New from the Disk Utility Image menu.
  3. Enter a name in the Save As field. This name is used for the disk image (.dmg) file.
  4. Change the save destination if you wish to.
  5. Select a size for the image file from the Volume Size pop-up menu (Size in Mac OS X 10.3) .
  6. Choose a volume format if you don’t want to use the default Mac OS X Extended (Journaled).
  7. Choose an image format. You can use “sparse disk image” for a disk image that only uses as much space as it needs, rather than a set amount of space. If you’re not sure, use “read/write disk image” choice.
  8. Choose 128-bit AES (and/or 256-bit AES in Mac OS X 10.5 or later) from the Encryption pop-up menu to encrypt the image’s contents with a password. If you don’t choose an encryption, your new image won’t be encrypted.
  9. Click the Create button.
  10. Enter and verify a good password in the dialog window that appears. This password will be saved in your keychain by default, or you can deselect “Remember password (add to keychain)” if you don’t want that. You can store the password in the keychain both for convenience and for reducing risk of password loss.
  11. Click OK.

Important: If you forget the password, data stored in the encrypted disk image cannot be retrieved. If you have saved the password in the keychain file, the password will be available to you there.

  1. Choose Apple menu > System Preferences, click Security, and then click FileVault.
  2. If the Security preferences pane is locked, click the lock icon, and then type an administrator name and password.
  3. If the Security preferences pane shows that a master password hasn’t been set, click Set Master Password, and then type a password in the Master Password box.  Please remember to set a Master Password.  This will allow you to recover your data if you forget your normal login password.  Especially useful for IT deptartments.
  4. Type the password again in the Verify box.
  5. Type a hint in the Hint box to help you remember the password.
  6. Click OK.
  7. Click “Turn on FileVault.” If you want to be sure your deleted files can never be recovered, click “Use secure erase.”
  8. Click “Turn on FileVault.”

Alternatively, if you are just concerned about hiding the files, and their contents…  There are a few ways to do this as well…  Some extremely simple, since Mac OS X is a version of Unix.

  • Place a period (.) as the first character in the file or folder name, and watch it instantly disappear.

The following bit of Applescript will allow you to turn on or off the displaying of hidden files in the Finder.

tell application "Finder" to quit
display dialog "Show Hidden Files..." buttons {"ON", "OFF"} ¬
  default button 3
copy the result as list to {buttonpressed}

try
  if the buttonpressed is "OFF" then do shell script ¬
    "defaults write com.apple.finder AppleShowAllFiles OFF"
  if the buttonpressed is "ON" then do shell script ¬
    "defaults write com.apple.finder AppleShowAllFiles ON"
end try

tell application "Finder" to launch

Feel free to suggest alternatives in the comments section…