Can't remove file from trash I'm having trouble emptying the trash on Catalina.  FileVault is enabled.  Trying to empty from Finder warns X11R6 can't be modified or deleted because it's required by macOS.  It's a link to /opt/X11 which is a regular directory.

OK let's try in Terminal:

fifteen:.Trash elliott$ pwd; ls -al
/Users/elliott/.Trash
total 272
drwx------    4 elliott  staff     128 Nov 11 21:44 .
drwxr-xr-x@ 125 elliott  staff    4000 Nov 10 22:23 ..
-rw-r--r--@   1 elliott  staff  135172 Nov 11 21:44 .DS_Store
drwxr-xr-x    3 root     wheel      96 Nov 11 21:42 Security

fifteen:.Trash elliott$ sudo rm -rf Security/
Password:
rm: Security//usr/X11R6: Operation not permitted
rm: Security//usr: Directory not empty
rm: Security/: Directory not empty

fifteen:.Trash elliott$ ls -l Security/usr/
total 0
lrwxr-xr-x  1 root  wheel  8 May 19 11:37 X11R6 -&gt; /opt/X11


I have already given Terminal full disk access in System Preferences.

Checking the rm command with dtruss I see it fails here:

unlink(".Trash/Security/usr/X11R6\0", 0x0, 0x0)      = -1 Err#1
write_nocancel(0x2, "rm: \0", 0x4)       = 4 0
getrlimit(0x1008, 0x7FFEED8FA680, 0x0)       = 0 0
write_nocancel(0x2, ".Trash/Security/usr/X11R6\0", 0x19)         = 25 0
write_nocancel(0x2, ": \0", 0x2)         = 2 0
write_nocancel(0x2, "Operation not permitted\n\0", 0x18)         = 24 0


I also verified that this file is on the read-write Data partition:

sh-3.2# ls -l /System/Volumes/Data/Users/elliott/.Trash/Security/usr/
total 0
lrwxr-xr-x  1 root  wheel  8 May 19 11:37 X11R6 -&gt; /opt/X11
This is a known issue that has impacted a number of users following an upgrade to Catalina1.

The best way to resolve this is to disable System Integrity Protection (SIP), delete the files/empty the trash, then re-enable SIP.

Full instructions provided below for the benefit of users unfamiliar with the process of disabling/enabling SIP: 


Startup (or restart) your Mac
Immediately hold down the commandR keys to boot into recovery
Click the Utilities menu and select Terminal
Type csrutil disable and press return
Close the Terminal app
Restart your Mac
Delete the files and/or empty the trash
Restart your Mac
Immediately hold down the commandR keys to boot into recovery
Click the Utilities menu and select Terminal
Type csrutil enable and press return
Close the Terminal app
Restart your Mac


1. In most cases, the affected users had XQuartz installed prior to the Catalina upgrade and during the upgrade process XQuartz isn't uninstalled properly.