Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Realizing that it is possible to change the prefs check-off box in Finder to hide the Hard Drive icon, how would you do this from the command line interface? I.e. what and/or where is the CLI command that emulates the check-off box?

share|improve this question

For hiding the Hard Drive you can modify Finder's preferences using the defaults command.

Specifically you would want to run:

defaults write ShowHardDrivesOnDesktop -bool NO

and relaunch the Finder (using killall Finder for example)

For hiding files in general from Finder you can either have . in front of the filename (eg. .hidden Folder), by turning on the invisible flag using SetFile, or using chflags.

/usr/bin/SetFile -a V /PATH/TO/FILE/OR/FOLDER

chflags hidden /PATH/TO/FILE/OR/FOLDER

To reverse:


chflags nohidden /PATH/TO/FILE/OR/FOLDER

SetFile is installed by default in Snow Leopard but previous versions required you to install the Developer Tools.

share|improve this answer
Your one works if you state NO rather than YES (OP wanted to hide not show) – Rob Cowell Jan 13 '10 at 18:05
instead of setfile which requires snow leopard, you can use 'chflags hidden /path/to/file'. – yanokwa Jan 13 '10 at 18:38
Fixed and added bits about chflags. Thanks, I forgot about chflags. – Chealion Jan 14 '10 at 16:15

I think you're looking for SetFile's invisible attribute which can be used on files and folders:

SetFile -a V /path/to/folder

SetFile is not included by default in versions prior to Snow Leopard, but you can get it from the Apple developers kit.

share|improve this answer

Disclaimer : This is not the right answer yet, but hopefully someone can build upon it to make it work :-

defaults write ~/Library/Preferences/ ShowHardDrivesOnDesktop -bool false && sudo killall Finder
share|improve this answer
Chealion's version is better (if you say NO rather than YES) - the difference seems to be not specifying a specific path to the plist and just writing to – Rob Cowell Jan 13 '10 at 18:05

You must log in to answer this question.