65

Ever since buying a new Mac, which has forced me to upgrade to Catalina, I cannot view the Trash folder in the Terminal. ls ~/.Trash just gives ls: .Trash: Operation not permitted. So does sudo ls ~/.Trash. According to ls -al ~, the permissions for ~/.Trash are drwx------, and the owner is me. sudo chmod a+x ~/.Trash and sudo rm -rf ~/.Trash both fail with the same error.

Is it possible to view the Trash in the terminal in Catalina?

1

2 Answers 2

105

You have to give the Terminal.app Full Disk permissions in the security settings.

enter image description here

6
  • 3
    Interesting! While this may seem like a giant hassle, it's clear to me that this decision could also potentially block a whole lot of malware. I think I actually support this design decision on Apple's part. Commented Jan 23, 2020 at 21:29
  • 1
    This answer helps a lot, thanks. But it also leaves new questions: a. What's the mechanism whereby some files/folders are made special this way? It's not just ~/.Trash, many subfolders of ~/Library/Caches for instance are also "untouchable". As not even the superuser can see them, it's clearly no traditional Unix mechanism; it is also not one of the file "flags" as ls -ldO ~/.Trash shows. And b. How can we see which files/folders are this kind, from the Unix side or otherwise? Other than trial and error, I mean.
    – q.undertow
    Commented Feb 6, 2022 at 3:01
  • And What Do You Know: even after this, some folders are still untouchable! Example here: gist.github.com/nobrowser/787f64a628c32d0e98379a0771bdf764
    – q.undertow
    Commented Feb 6, 2022 at 3:41
  • 1
    I believe you are referring to chflags, which can be modified by using the chflags command. I would recommend reading the man page. I would also like to caution against changing chflags for system files as it can cause issues.
    – virus.cmd
    Commented Feb 6, 2022 at 3:50
  • @virus.cmd perhaps, but I wasn't necessarily thinking about changing them, in fact they are apropos to the main issue here. Which is kind of the whole point of my comment :-)
    – q.undertow
    Commented Feb 6, 2022 at 18:00
0

I have gone through many solutions and this one is the best. Let me tell you that this also does not help to delete the files but makes life easy.

By giving the 'Full Disk Access' to terminal you can actually go inside with 'cd' and see the content and even by giving '777' permission to all the content there you can move everything outside '.Trash' in some other folder and keep the stuff parked there. This will get away the annoying 'Files are in use' warning and you can use empty your trash bin normally.

This is a great solution, if you do not mind one unnecessary folder of 0 size lying in your disk.

You must log in to answer this question.

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