2

This question already has an answer here:

In terminal I just type firefox and then Firefox starts, but I can not return to command mode anymore.

How can I come back to command mode?
I have already tried :q or exit, but neither work.

marked as duplicate by jasonwryan, slm Jul 18 '14 at 23:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    If, by command mode, you mean the interactive shell, then no. You have run firefox in such a way so that the terminal will show its output. You can press ^C to send SIGINT to firefox. Doing so will get you back to the interactive shell, but it will kill firefox. Instead, you can run firefox in the background (à la firefox &), and you should already be back to the interactive shell once the process has forked off. – HalosGhost Jul 18 '14 at 21:27
  • 1
    ...firefox & is the right way. If you forget it you can do CRTL-Z to suspend it and after %1 & to execute it in background. – Hastur Jul 18 '14 at 21:54
6

When you run a program from a shell (e.g. firefox) it will be executed "in foreground". When the program will finish you will have back the possibility to execute another command.

Another way to execute a command is "in background". If you put this symbol & after the command it will be executed asynchronously (in background) and you will have the possibility to execute other commands from the same shell/terminal. Excerpt from man bash:

When bash starts a job asynchronously  (in the background), it prints a line
that looks like:  

          [1] 25647

indicating  that this job is job number 1 and that the process ID of the 
last process in the pipeline associated with this job is 25647.

When you start the second jobs it will answer with [2] NewPid and so on. With the built-in command jobs you will have all the list.

When you run a command "in foreground" and you want to suspend it (not to stop definitively) you can press CTRL+Z. The shell will answer you in a similar way (e.g.)

 [1]+  Stopped                 firefox

To continue the precedent job you can write %1 & (the same number you read from the terminal). You can also do it with bg %1. It will execute the job 1 in background and give you the prompt back, ready to accept new commands.

You may find interesting the article Linux: Start Command In Background

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