1

I used to use the purge command in Terminal to flush my buffers on my Macbook Pro (mid-2012). Then, I upgraded to OSX Mavericks, and when I tried purge again, I got this output:

Unable to purge disk buffers: Operation not permitted

I have tried everything to authenticate it, I even used sudo before it, but nothing has worked so far. What is the cause for this and how can I fix it?

  • 1
    Sanity check: Are you aware that using purge does not speed up your computer? (In fact it probably slows it down). Free memory is unused memory which might as well be in a desk drawer then inside the computer. Memory assigned to buffers is useful (and gains you speed) and if more free memory is needed than is available then the OS will free (purge) these buffers on its own. – Hennes Nov 8 '13 at 12:55
  • Yes I am aware of that, I use purge to free up the buffers before starting a heavy game. – Vedant Chandra Nov 8 '13 at 14:31
  • I do not have a Mac (and thus no OS X) to test things on, but Operation not permitted sounds like insufficient rights to do so. Can you add the output of ls -l $(which purge) or trace the call with /usr/bin/dtruss to see where the error originates? – Hennes Nov 8 '13 at 14:40
  • Could you please clarify? – Vedant Chandra Nov 8 '13 at 15:53
  • Doing kernel related (like flushing buffers) either requires high level access (e.g. execute by root/uid0) or a way to elevate to that level. The last is usually done by making a file either uid or guid 0 (root:root or root:wheel) and setting the suitbit. ls -l on the purge binary will show if that bit is set. ( The $( ) starts a subshell and returns the value. In this case it is intended to locate the binary and then feed that output to the ls command. Akind to which purge -> purge is in /some/folder/purge and then doing a ls -l /some/folder/purge. (all from the shell ofc) – Hennes Nov 8 '13 at 16:12
1

Answer blatantly copied from our sister site:

You need to run this command with root privileges. You can do that in several ways:

1) Elevate one command to uid 0 rights with the sudo command:

> sudo purge

    WARNING: Improper use of the sudo command could lead to data loss
    or the deletion of important system files. Please double-check your
    typing when using sudo. Type "man sudo" for more information.

    To proceed, enter your password, or type Ctrl-C to abort.

    Password:

Enter your account's password and it should run the purge command.


If you do not want to enter a password, add %localaccounts ALL=NOPASSWD: /usr/sbin/purge to sudoers. (From a shell run sudo visudo, press i, type or paste the text, press escape, and type :wq.) Then use a Run Shell Script action that runs sudo purge.


2) Log in as root and issue the command.

Optionally after enabling the root account


3) From your terminal prompt (a bash shell) type su -, the root password and then /usr/sbin/purge.


Apple probably made the decision for security purposes. The only disadvantage is you have to type in your admin password. The advantage is, for non-admin users, they can not run this command and potentially harm their OS.

Usually commands that require sudo in order to run at all are potentially destructive or invasive. Two other commands with this requirement are dtrace and xcode-select.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.