bash – “cannot execute binary file” when using su

SubhamSeptember 30, 2022
Spread the love

The following works.

$ ls -d /tmp

But if I try to execute it with su it doesn’t work.

$ su otheruser ls -d /tmp
/bin/ls: /bin/ls: cannot execute binary file

Then, if I become the user, it works again.

$ su - otheruser

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit
$ ls -d /tmp

Any idea what’s happening here? I’m running Monterey on an Intel Mac.


Leave a comment

Name *
Add a display name
Email *
Your email address will not be published