bash – “cannot execute binary file” when using su

SubhamSeptember 30, 2022
Spread the love


The following works.

$ ls -d /tmp
/tmp@

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

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

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

$ su - otheruser
Password:

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 https://support.apple.com/kb/HT208050.
$ ls -d /tmp
/tmp@

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

Categories

Leave a comment

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