Skip to main content
Question

Editing Plists - what's the difference?

  • June 4, 2019
  • 3 replies
  • 23 views

Forum|alt.badge.img+5

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

Forum|alt.badge.img+19
  • Contributor
  • June 4, 2019

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.


Forum|alt.badge.img+5
  • Author
  • Contributor
  • June 4, 2019

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


talkingmoose
Forum|alt.badge.img+36
  • Community Manager
  • June 5, 2019

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.