Score:1

Cannot delete directories as sudo: Permission Denied

gu flag

I am trying to remove directories with files and getting a permission denied error on Ubuntu 22.04.1.

I've changed permissions to 777 for the directory and the parent directory but I still get the error.

Screenshot of the error

$ sudo rm *.* 
rm: cannot remove 'Real Economy v1.5.1-4267-1-5-1-1588544476': Permission denied
rm: cannot remove 'Witcher 3 input.settings file backup for 1.32-5844-1-32-1626358844': Permission denied

Additional

The directory containing the directories/files I'm trying to delete is a default download destination for Brave Browser and also Firefox. It's on the system disk (SSD). The browsers also won't allow me to change the download destination, which is weird. The files were downloaded here and are intended for Windows (mods for Witcher 3).

The other weird thing is that these are extracted archives (7-zip files, etc).
I CAN delete the original archive file, but once I extract it, I CAN'T remove the extracted directories/files.

karel avatar
sa flag
Does this answer your question? [How to delete a non-empty directory in Terminal?](https://askubuntu.com/questions/217893/how-to-delete-a-non-empty-directory-in-terminal)
Score:12
jp flag

Besides file permissions there are (at least) 5 more things that can influence your ability to delete things:

  • Extended acl's (man getfacl)
  • File attributes (man chattr)
  • Fileystem mount options (man mount)
  • Linux security modules (man apparmor)
  • And for remote filesystems (nfs, cifs, ...) all of the above again, but on the remote side. Plus remote-mount specific limitations (e.g. cifs servers refusing deletes from clients)
Artillery avatar
gu flag
The directory is a default download destination for Brave Browser and also Firefox. Its on the system disk (ssd). The browsers also wont allow me to change the download destination, which is weird. The files were downloaded here and are formatted for windows,(mods for witcher3)
Artillery avatar
gu flag
Tried looking at file attributes but there's nothing there
Artillery avatar
gu flag
lsattr -R * lsattr: Function not implemented While reading flags on content/content0 (there's hundreds of lines like this for each file)
Artillery avatar
gu flag
Also tried $ chattr -i -R *.* chattr: Function not implemented while reading flags on Real Economy v1.5.1-4267-1-5-1-1588544476 chattr: Function not implemented while reading flags on Witcher 3 input.settings file backup for 1.32-5844-1-32-1626358844
iBug avatar
tr flag
Normally the root user has `CAP_DAC_OVERRIDE`, which means any access control at VFS level (file modes, ACL etc.) shouldn't matter. Your other arguments are valid.
cn flag
For NFS, there's also a server option where client superuser is translated to `nobody`.
Score:2
gu flag

I figured it out. It's because it's directories I'm trying to delete. For anybody else who gets this problem, the command is

rm -rf 'directory name'

That removes the directory and all subdirectories and files. Thanks to everyone for their input.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.