Skip to content

Instantly share code, notes, and snippets.

@innyso
Last active January 16, 2021 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save innyso/4ea66ce8a9e9ac1839e55fd7f415fa18 to your computer and use it in GitHub Desktop.
Save innyso/4ea66ce8a9e9ac1839e55fd7f415fa18 to your computer and use it in GitHub Desktop.
#linux #process #foreground #background #cmd #bg #fg

Linux foreground background process

Foreground Process

A command or process you run directly and wait for it to complete

Background Process

The shell does not need to wait for the process to end. You can run as many of background process as you want within your system memory limit.

To run a background process, issue a command follow by an ampersand, the shell execute the command but instead of waiting, it return to the shell immediately.:

command &

Note background job run as lower priority compare to foreground job

Switching between process

  • Ctrl + Z: suspend foreground process
  • bg: resume suspended process in the background
  • fg: resume suspended process In foreground
  • jobs: see a list of suspended processes

My usual vim workflow

  • open vim and do whatever I need, save :w and suspend vim process using Ctrl-Z in normal mode
  • do whatever I need in the shell, resume vim session by typing fg

Normally I check the number of suspend vim I have by using jobs command. I should onl have one suspended vim process.

References

https://www.lifewire.com/multitasking-background-foreground-process-2180219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment