GhostCat
GhostCat

Reputation: 140465

Why can't I create links in /bin?

I am using MacOs Mojave, and I figured that the env binary sits under /usr/bin/env. Now we have a bunch of shell scripts (written and working under linux) that have /bin/env hardcoded for the shebang line.

I thought a simple:

cd /bin
sudo ln -s /usr/bin/env env

or maybe

sudo cp /usr/bin/env .

should do the trick, but I get:

ln: env: Operation not permitted

(same for cp).

Any idea how to fix this?

Upvotes: 2

Views: 71

Answers (1)

L3viathan
L3viathan

Reputation: 27283

While you could go ahead and disable System Integrity Protection, I do not recommend it.

Instead, change your shebangs to use /usr/bin/env; that's where env belongs.

Apparently some Linux distros contain env both in /bin and in /usr/bin, but some (including Debian and probably derivatives) don't. Neither does macOS, and I bet other BSDs don't, either.

Upvotes: 2

Related Questions