Linux Labs

Users, permissions, and processes / Stage 11 of 13

Background jobs and the terminal

Not running Starting usually ~20 s
Leave the lesson

Step 7 of 7 · summary · 2 min

Summary

  • & at the end of a line runs a command in the background: the prompt comes back at once, and [1] 1028 is the job number and the PID.
  • jobs shows this shell's jobs, and ps the processes of the whole machine.
  • Ctrl+Z pauses a command, bg continues it in the background, fg brings it back to the terminal, and Ctrl+C interrupts it.
  • %1 is a job number, while kill takes a number without % for a PID. wait $! waits for a background command, and $? holds its exit status.
  • At the start of the lesson the prompt came back at once while sleep 600 kept running: & had sent it to the background.
Ubuntu 24.04
Loading…