How to list the Mail directory from the Terminal?

Is there a way to change the file or directory permissions so that I can list the contents of the Mail directory from the Terminal command-line in macOS 10.15.4?

When trying to list the contents, I currently get this error.

$ cd ~/Library/Mail 
$ ls -l 
ls: .: Operation not permitted

The Mail app works without issues. I can see the contents of the Mail folder in the Finder by using the Option key. On earlier macOS versions, I could list the contents from the Terminal without issues. But not any more after migrating to a new MacBook Pro running 10.15.4. What changed?


Solution 1:

You need to give Terminal Full Disk Access in System Preferences > Security.