Unable to delete files through Terminal

12,831

It seems that your file was created using superuser sudo (root/admin) attributes so, in order to modify o delete this file you would need to authenticate as a 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 folder all its content will be removed. Your machine will ask you for sudo password. Consider that after this instruction the files will be completely removed!.

Share:
12,831

Related videos on Youtube

ALX
Author by

ALX

Updated on September 18, 2022

Comments

  • ALX
    ALX almost 2 years

    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.

    • text
      text almost 8 years
      It probably has to do with the permissions on the directory not the file.
    • ALX
      ALX almost 8 years
      I believe that is true @mdpc, I am asking how to override that I guess. I probably should have made that more clear.
    • text
      text almost 8 years
      A solution would be to change the directory permission.
    • thrig
      thrig almost 8 years
      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.
    • ALX
      ALX almost 8 years
      And that is with the shift key, correct?
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 8 years
      Which files, precisely? IIRC recent versions of OSX make some parts of the system read-only even to root.
  • zyy
    zyy over 4 years
    I thought sudo is deprecated on mac, but it worked!
  • Admin
    Admin about 2 years
    When I sudo it still doesn't work. I think something is really messed up on my system.