Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using chroot in a script, the purpose is to run a command, here is chroot syntax:


The problem is the command I am running needs to take a variable defition, like this -

chroot   /myroot   FOO=BAR  my_cmd

But when I do this, I get error message bash : FOO=BAR, no such file or directory, looks like the first position must be command.

Is there a workaround of this?

share|improve this question

This seems to work:

$ sudo FOO=bar chroot /srv/Chroot/precise-i386/ env | grep FOO
share|improve this answer

You can also use alias here . for example

alias foo= 'your command '

place this command in your bashrc with

gedit .bashrc

then do source .bashrc

do all these in your terminal .

some one edit my post to put it in format because I'm doing this from my mobile .

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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