Editing Plists - what's the difference?

Gascolator
New Contributor III

Noob scripting question. When using a script to edit a plist, what's the difference between:

/usr/bin/defaults write ........

and just doing

defaults write........

3 REPLIES 3

ryan_ball
Valued Contributor

You are specifying the full path of the command with /usr/bin/defaults. This is more desirable as you might get mixed results with some commands when running in different contexts, like Daemons etc.

You can find the full path of a command by: which defaults or command -v defaults.

Gascolator
New Contributor III

@ryan.ball Thanks. I had seem some scripts written with it and some without and couldn't distinguish why. That makes sense.

talkingmoose
Moderator
Moderator

Using the full path to a command, which is really just a file, is a security measure. This ensures the defaults command you want to run is this one located at /usr/bin/defaults and not this one at ~/Library/.hidden/malicious/keylogger/defaults.