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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

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

7 Comments

» Comments RSS Feed

  1. Franck says:

    Unfortunatelly, this does’t work for symbolic link !

  2. Peter says:

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

  3. 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.

  4. 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/

  5. Vinod says:

    Wow experience!! Worked!!

  6. 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 :(

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

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