A program in execution is called process. each process will have unique process id.
How do I differentiate the process is running in foreground/background ?
if the user needs to wait for the result of the program, then the job is running in foreground. This also means if the user log out the terminal, then the job will get killed. In case of back ground jobs , when the user runs the program, he will run with (&) symbol where he will get the job id of the process running in background.
How I can run the programs in background ?
program_name arguments_input &
or
nohup program_name arguments_input &
How do I know how many jobs are running in background ?
jobs command will allow the user to know the jobs running in background with job id
How do I can move the process from foreground to background ?
- run the process in foreground
- press control+z, the process will get stopped
- and run immediately with the command bg
run the jobs command and view the job id of the program that we want to move to foreground.
fg %job_id
fg %starting name of process
will allow the process to move from background to foreground