6

I'm opening firefox via the terminal using

firefox

but I can not type any other command after this one since I don't regain control of the terminal after having typed that.

The only way to do so (for me) is to press CTRL + Z but then firefox freezes.

I'm using Lubuntu and am not totally new to it but haven't used it as much as Windows.

2
  • 1
    Why do you start Firefox in terminal?
    – Pilot6
    Jul 24, 2016 at 17:19
  • 5
    @Pilot6 Why not ? It's easier given the different shortcuts I'm using. Jul 24, 2016 at 17:20

2 Answers 2

20

The obvious way to go is to launch such applications in background by adding an & sign to the end of the command, like this:

firefox &

Please note that Firefox is now a child process of your shell and your terminal window. If you exit them, Firefox gets killed if it's still running. To avoid this and make sure it continues running even after closing the terminal, you must disown it:

firefox & disown

If you already started firefox (or any other application) in foreground, you can still send it to the background though. Focus the terminal and hit Ctrl+Z. This freezes the foreground application and gets you back to the shell. You can now immediately run the command bg to send the just frozen process to the background and let it go on running.

3
  • I'm glad you got that accept :) thanks for teaching
    – Zanna
    Jul 24, 2016 at 18:05
  • @Zanna And I'm sorry for stealing it from you - again ;)
    – Byte Commander
    Jul 24, 2016 at 18:07
  • Hey @Zanna I'm really sorry to have taken it from you but this answer was better in terms of long term documentation (for future users who might encounter the same problem). But why did you delete yours? You lost the rep of my upvote doing so. Jul 24, 2016 at 19:24
6

You can type

firefox &

to tell firefox to run in the background, then you can keep using your terminal session...

Edit: And @ByteCommander has explained this much more thoroughly than me.

But sometimes Firefox (or another process that has been told to run in the background) will print some warnings and so on to the terminal, even if the process is running in the background and has been disowned. If you don't want that you can tell it to be quiet by redirecting stdout and stderr

firefox >/dev/null 2>&1 &

and disown if you like. This will give you the PID of the child process and send any output from it straight to data Nirvana (@Videonauth's phrase), so you can carry on in the blissful certainty that you won't be interrupted. Note that you have to do this when starting a process; it can't be added later.

0

Not the answer you're looking for? Browse other questions tagged .