Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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 trying to start a file compare application from the console by runnning bcompare ... & but this will start the application without activating it (focus).

Is there a way to start it and switch to it? I'm looking for something similar to Windows start command.

share|improve this question
up vote 1 down vote accepted

You can do it with wmctrl Install wmctrl. Install it with sudo apt-get install wmctrl.

Manual: [wmctrl manpage]


wmctrl -a chrome

Switches to the desktop containing the chrome window, raises it, and gives focus.

So after starting your program, run wmctrl -a bcompare.

As for your request, this is a not-so-elegant-way to check if the command is available, and if not it, try to install the package. (Consider it a bad hack, I think it should be a different question to answer this properly. For starters: it should have queried the package database.)

installed=`type -p $required_command`
if [ "$installed" == "" ]
    sudo apt-get install "$package"
share|improve this answer
Thanks! Extra points if you update the command to try to install wmctrl if it does not exist ;) – sorin Mar 30 '12 at 13:19
Added a simple installation method if the command does not exist, but it is more of a joke, rather than a real solution. – lgarzo Mar 30 '12 at 13:52

append with & . It denotes background application.


chrome &

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.