Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

closed as unclear what you're asking by Tog, Kevin Panko, MariusMatutiae, Moses, Garrett Jul 8 '14 at 17:10

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

    
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

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
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.