6

More recently, I have been using rm -r /path/to/file to delete files, but when deleting from certain locations, I get the error: override rw-r--r-- root/admin for filename? I have tried entering y, but I get the error: rm: filename: Permission denied. I have also tried rm -rf and yes | rm -r with the error rm: filename: Permission denied again. Is there any way to bypass this strange issue? My operating system is Mac OSX Yosemite, and I am using Terminal.

6
  • It probably has to do with the permissions on the directory not the file.
    – mdpc
    Commented Jul 19, 2016 at 22:47
  • I believe that is true @mdpc, I am asking how to override that I guess. I probably should have made that more clear.
    – ALX
    Commented Jul 19, 2016 at 22:48
  • A solution would be to change the directory permission.
    – mdpc
    Commented Jul 19, 2016 at 22:48
  • 1
    What are the permissions on /path/to, does chflags show anything interesting on any of the files or directories involved, and you might need to boot in rescue mode to delete some of the really restricted files in recent OS X releases.
    – thrig
    Commented Jul 19, 2016 at 22:49
  • And that is with the shift key, correct?
    – ALX
    Commented Jul 19, 2016 at 22:50

3 Answers 3

4

It seems that your file was created using by the root user so in order to modify o delete this file you would need to authenticate as root using sudo. To do this simply type:

sudo rm -rf path/to/file

Here, rm -rf stands as remove recursively so that if path/to/file is a directory all its content will be removed. Your machine will ask you for your password. Consider that after this instruction, the files will be completely removed!.

0
1

I have found on MacOS that:

chmod u+w FILE
rm -f FILE

or

chmod -R u+w DIR
rm -rf DIR

fixes some "Permission denied" problems.

0

You could try to delete the folder with sudo.

sudo rm -rf foldername

You must log in to answer this question.

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