Basically I have two jobs:

  1. Compiling a code
  2. Download a youtube video with using youtube-dl command

Both of the above commands use the terminal. I want to execute both of these commands in the same shell. I don't want to use another terminal, nor do I want to use another tab. I read something there is a command fg to do that stuff but don't know how to use it. Suppose I have started downloading video using youtube-dl. How can I hide that process and compile codes. And once I am done compiling I switch over to see how much the video has downloaded and vice-versa.


You can use screen. This allows you to set up new screens in your shell which you can switch between.

Quick reference guide:

  • ctrl-C creates a new screen
  • ctrl-N switches screens
  • ctrl-D ends screen
| improve this answer | |
  • 1
    This is often the easiest option for commands that produce output while they're running. Otherwise the command you've pushed to the background will continue to write to the terminal window while you're trying to enter other commands, unless you redirected its output to a file or elsewhere instead. – calum_b Oct 16 '14 at 7:57
  • Screen or tmux is clearly the best way to go here... – bmike Oct 16 '14 at 21:06

The easiest way to run a command in the background is to put an & at the end of the command. It will start, and return you to the prompt immediately.

Another way would be to suspend the current process with CTRLz, and type bg, the corollary to the fg command you already looked up.

| improve this answer | |
  • Thanks for clearing it out. I had a this problem with suspending a task. I was wondering how to type command while video is downloading. :) – Stack Overflow 32 Oct 16 '14 at 7:02
  • i tried but ctrl z doesn't work, the video is downloading and i can't write any command – Stack Overflow 32 Oct 16 '14 at 7:03

You must log in to answer this question.

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