Prefixed with a dot
As in all Unix/Linux systems, a file starting with a dot is generally hidden in desktop managers (thus, Finder) and "normal" folder listings done through a shell (ls
). Listing a folders contents with ls -a
however reveals those files.
For example, a normal listing:
charon:portal werner$ ls -l
total 56
-rw-r--r--@ 1 werner staff 920 Aug 17 12:58 Gemfile
… and with the "all" option:
charon:portal werner$ ls -la
total 96
drwxr-xr-x 25 werner staff 850 Sep 14 16:08 .
drwxr-xr-x@ 9 werner staff 306 Jun 15 14:57 ..
-rw-r--r--@ 1 werner staff 12292 Sep 20 15:46 .DS_Store
drwxr-xr-x 15 werner staff 510 Sep 28 22:24 .git
-rw-r--r-- 1 werner staff 51 Aug 17 13:38 .gitignore
-rw-r--r--@ 1 werner staff 920 Aug 17 12:58 Gemfile
The Finder in OS X can also show files and folders that were hidden by the dot prefix by entering:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
This can be reversed by exchanging TRUE
to FALSE
, obviously.
Changing the "hidden" flag
You can change the "hidden" flag of a file or folder by using the following commands:
chflags hidden some-file
chflags nohidden some-file
Hiding a file with flags will, as above, obviously only hide it from Finder itself. You will still be able to see the file with ls
. If you want to see which are really hidden, you can check these flags with ls -lO
:
charon:~ werner$ ls -lO
total 0
drwxr-xr-x 11 werner staff - 374 May 13 16:43 Binaries
drwx------+ 8 werner staff - 272 Sep 30 09:48 Desktop
drwx------+ 10 werner staff - 340 Sep 25 21:38 Documents
drwx---r-x+ 11 werner staff - 374 Sep 30 15:46 Downloads
drwx------@ 18 werner staff - 612 Sep 30 14:02 Dropbox
drwx------+ 53 werner staff - 1802 Sep 29 20:04 Library
drwx------+ 6 werner staff - 204 Sep 25 21:38 Movies
drwx------+ 8 werner staff - 272 Sep 25 21:38 Music
drwx------@ 12 werner staff hidden 408 Sep 26 10:31 Pictures
drwxr-xr-x+ 6 werner staff - 204 Sep 25 21:38 Public
drwxr-xr-x@ 5 werner staff hidden 170 Sep 25 21:38 Sites
This will show "hidden" on all files hidden from Finder.
Of course, you can still open any of these files.
Through the terminal, by typing
open some-file
In Finder, going to Go » Go to Folder …, and entering the full path.
There is no "real" way to hide a file forever, or even hide it from the shell. At least for a user without access to a shell, these would be invisible.
Hiding a folder from other users
You can hide an entire folder from another user on the system. Set its permissions to full access for yourself and remove the permissions for others, by typing:
chmod 700 some-folder
This folder will be invisible and not readable from other users, but it's not a very practical thing to do.