You have a command line…how can you possibly achieve multitasking?
Let’s say you have a HUGE Java source to compile (using the javac command), but at the same time you want to look through your schedule (nano schedule.txt).
The compilation will take time, and you cannot wait.
So, you run the compilation in the background while looking through your schedule.
The “&” can be used to run a task in the background.
javac myProgram.java &
You can use the ‘bg’ command to put a job in the back-ground. (you can stop a task and return to the shell using Ctrl + Z)
Here the VI text editor is opened. Then after hitting Ctrl+z, we return to the shell and VI is stopped. Running bg causes it to run in the background (although running a text editor in the background is useless).
bg => run a program in background
fg => run a program in foreground
jobs => list all jobs (background + foreground)