Why is #!/usr/bin/env bash not working on my system?
ls -lL /usr/bin/env
shows that the symbolic link is broken. That explains why the shebang line isn't working: the kernel is trying, and obviously failing, to execute a dangling symbolic link.
/usr/bin/env -> ../../bin/env
is correct if /usr
and /usr/bin
are both actual directories (not symlinks). Evidently this isn't the case on your machine. Maybe /usr
is a symbolic link? (Evidently it isn't a symbolic link to /
, otherwise /usr/bin/env
would be the same file as /bin/env
, not a symbolic link).
You need to fix that symbolic link. You can make it an absolute link:
sudo ln -snf /bin/env /usr/bin/env
You can make it a relative link, but if you do, make sure it's correct. Switch to /usr/bin
and run ls -l relative/path/to/bin/env
to confirm that you've got it right before creating the symlink.
This isn't a default RHEL setup, so you must have modified something locally. Try to find out what you did and whether that could have caused other similar problems.