Quickly Hide a File in Mac OS X Using chflags

Jul 19, 2012 - 7 Comments

Hide a file in Mac OS X

Want to quickly hide a file from prying eyes? Just like you can hide folders, you can hide individual files too. Here is how to do this using the command line tool chflags.

Launch Terminal from /Applications/Utilities/ and use the following command syntax:

chflags nohidden /path/to/hide/file.txt

If you know the path to the file just type it yourself. If you don’t, follow the drag & drop method to automatically type the entire path within the Terminal, just be sure to drop it in after the initial command, and then hit the return key:

chflags hidden [DRAG FILE HERE]

If you’re confused at all watch the quick video below that demonstrates the command being used with drag and drop:

Note these files will be hidden to everyone unless if hidden files are shown in the Finder.

At any point you can unhide the file with the following chflags command:

chflags nohidden /path/to/hide/file.txt

chflags should be familiar to anyone who has used it to show the Library folder in OS X Lion or Mountain Lion. This is trouble-free alternative approach to the setfiles method, which requires Xcode Developer Tools to be installed to use. You can also throw a period in front of a file or folder name to hide it from the Finder in OS X.


Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. Annica says:

    when i typed ‘ chflags hidden ‘ and drag folder to it, it appears as usage: chflags [-fhv] [R [H | -L | -P]] flags file …
    How can i do ? plz help :(

  2. Vinod says:

    Wow experience!! Worked!!

  3. Mikee says:

    but make sure you remember the filename which you have make hidden.. or use “tab” button to reveal filename on terminal under /correct path/

  4. OSX-newbie says:

    If there is a way to hide a file, then there should also be a way to unhide it. How to do it in the terminal command? thanks in adv.

    • Will says:

      Oops! Updated the article to reflect unhiding, the command is:

      chflags nohidden /path/to/hide/file.txt

  5. Peter says:

    It also works for encrypted disk images/sparse images/sparse bundles, adding a bit more security for sensitive financial etc., data.

  6. Franck says:

    Unfortunatelly, this does’t work for symbolic link !

Leave a Reply


Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site