24

I am trying to delete a directory on OS X. I do rm -r /path/dir but I keep getting many, many messages like this:

override rw-r--r--  root/wheel for cron/migrate.php? 

I type y for one message, but then another one pops up. I would like to override the message for the whole directory in one command. How do I do that?

2
  • 1
    Step 1: brew install git Step 2: brew link git or brew link --overwrite git Step 3: git version Enjoy the latest git version on macOS.
    – ob1dev
    Commented Apr 19, 2020 at 20:06
  • Pretty sure the march of time has rendered the answers here incorrect. I should note that, at time of asking, the answers above were probably correct, but several years on, that is no longer true. For a better answer in 2022, go to AskDifferent, and ignore all the hand-waving non-answers and see the reply on Nov 6, 2015 at 15:44 by prosseek. Delete unnecessary files in /System/Library for Mac OS X
    – BISI
    Commented Feb 7, 2023 at 17:45

3 Answers 3

27

First approach is, using -f option for rm command:

rm -rf /your/path

Second approach is,

yes | rm -r /your/path

First approach used more for your purpose and second approach used more for copy or moving files.

1
  • 3
    wow, I finally learned why the "repeat" command is called yes!
    – wisbucky
    Commented Apr 5, 2018 at 23:52
9

Use the -f flag to rm

rm -rf /path/dir

This wont ask you any questions, anything that you can delete will be deleted.

0

One way to delete files that don't belong to you is to do it as root.

sudo rm -R /path/to/dir

This overcomes most permissions that cause the override prompt. There can still be times when permissions are set to prevent root accidentally deleting files at which time preceding the rm command with sudo chmod -R 777 /path/to/dir can be helpful.

Remember that you need to be sure you want to delete the files and that your path is correct.

2
  • this needs the account to be registered in /etc/sudoers - which is one of the brakes that should prevent users from doing what they shouldn't do. Otherwise, thankfully!, this would be pretty useless!
    – erch
    Commented Dec 10, 2013 at 18:50
  • 1
    The user mentions being on OSX - a user account with admin privileges on OSX has access to sudo without modifying sudoers. If he didn't have an admin account he shouldn't be able to delete files owned by root by saying yes to override.
    – sambler
    Commented Dec 10, 2013 at 23:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .