20

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?

1
  • 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.
    – Oleg Burov
    Apr 19, 2020 at 20:06

3 Answers 3

26

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
    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
    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
    Dec 10, 2013 at 23:22

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