I want to automatically execute commands with the prefix /usr/bin/env

$/usr/bin/env composer install (this runs OK)
$/usr/bin/env cd public (failed ---> /usr/bin/env: cd: No such file or directory)

I'm new to Linux and in my opinion, using /usr/bin/env is a weird way to write commands. I wonder why my second line didn't work (while some worked, like mkdir or ls)

The reason I cannot get rid of /usr/bin/env is that I'm using Capistrano and it keeps prepending the prefix. If there is a way to get rid of /usr/bin/env, that's even better.

Thank you in advance.

  • It is unclear what you are trying to achieve and why you are using /usr/bin/env in the first place. – Pavel Šimerda Jul 8 '14 at 4:36
  • As I noted in the bottom, I'm using Capistrano to run commands on server via SSH, and many commands were prepended with this /usr/bin/env – Hoang Lam Jul 8 '14 at 4:37
  • It's not much better now. – Pavel Šimerda Jul 8 '14 at 4:39

You cannot run env cd /path/to/directory because there's no program called cd in your system. A process can change its working directory using a system call. In a shell you can use a builtin command cd. Calling it from env doesn't make any sense as it creates a new process that would exit just after changing its working directory. The new env process cannot change the working directory of the calling process in a standard way.

  • 1
    @Hoang Lam: See type composer and type cd. – Cyrus Jul 8 '14 at 5:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.