LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using Bash shell when I run a program from it (https://www.linuxquestions.org/questions/linux-newbie-8/using-bash-shell-when-i-run-a-program-from-it-880164/)

jimmyrp 05-11-2011 02:55 PM

Using Bash shell when I run a program from it
 
So I open firefox from my bash shell with:

Code:

firefox google.ca
it opens firefox, I can browse, etc.
Now if I alt-tab back into my shell, i can't enter any commands in the shell.

I know that i can do this if I close firefox, but I want to keep working in my shell with firefox still open.

Is this possible?

Hangdog42 05-11-2011 02:58 PM

Welcome to LQ!

firefox google.ca &

If you add an ampersand after a command, it detaches the command and you can get back to the prompt. The nohup command (nohup firefox google.ca) will do something similar.

If you really want to get fancy, you can use the screen command to create virtual terminals that you can detach and re-attach whenever you want.

jimmyrp 05-11-2011 02:59 PM

Thanks a lot!

r_s 05-11-2011 04:23 PM

press ctrl+z this will send the SIGSTOP signal.
Then type bg, this will send the process in the background, you can do fg to bring it in the forefront.

MTK358 05-12-2011 11:29 AM

Also, if you don't want output from the background command cluttering up your terminal as you work, do this:

Code:

firefox google.ca &> /dev/null &
And finally, remember to mark the thread as solved.

astromime 05-15-2011 12:39 PM

you can also check your jobs list for jobs running in the background with the command...jobs

so if you are running alot of commands in the background, use jobs to get the job number, and you can bring it to the foreground if you wish to by typing fg JOBNUMBER

not relevant here really, but useful

MTK358 05-15-2011 12:54 PM

Another useful tip: you can keep the command running after you close the terminal using the nohup command.


All times are GMT -5. The time now is 05:50 AM.