Operating instructions within the Linux terminal is probably going one thing you do almost day by day, however shifting a working course of into the “background” and later shifting it again into the “foreground” is one thing totally different altogether. When a course of is working within the foreground (the same old state of working instructions), it could possibly be stated to “personal your terminal”. In different phrases, you’ll possible sit and await it to complete earlier than you even attempt to run one other command. If a course of is more likely to take a very long time to finish, alternatively, you do have an choice aside from ready patiently for it to get accomplished. You possibly can transfer it into the background – releasing up your terminal window to run different instructions.
Transferring a course of to the background
To maneuver a course of into the background, you’d kind ^z (maintain the Ctrl key and press “z”) to droop it, after which kind bg to maneuver it into the background. The method will maintain working, however you’ll get your immediate again and be capable of work on one thing else whereas it’s nonetheless working to completion within the background. Word {that a} backgrounded course of will maintain working till it’s accomplished or till you sign off. Right here’s an instance:
$ sleep 1000 ^Z [1]+ Stopped sleep 1000 $ bg [1]+ sleep 1000 &
Checking on backgrounded processes with the roles command
To checklist backgrounded processes, use the jobs command like this: