# Jobs & Signals — Linux

Source: https://www.geekswithgeeks.com/en/linux/linux-jobs-signals

> Foreground vs background, and the signals behind kill.

## Foreground vs background

A **foreground** job occupies your terminal until it finishes. A **background** job (started with `&`) frees the terminal so you can keep working.

## &, jobs, fg, bg

Start a job in the background, list jobs, and bring one back to the foreground.

```bash
sleep 100 &
jobs
fg %1        # bring job 1 to foreground
# Ctrl+Z suspends the foreground job, then:
bg %1        # resume it in background
```

Output:

```
[1] 5231
[1]+  Running                 sleep 100 &
```

## Signals at a glance

`SIGINT` (Ctrl+C) asks a process to stop, `SIGTERM` (default `kill`) requests graceful shutdown, `SIGKILL` (`-9`) terminates immediately and cannot be caught or ignored.

**Quiz:** Which signal cannot be caught or ignored by a process?

- [ ] SIGTERM
- [ ] SIGINT
- [x] SIGKILL

*Answer:* SIGKILL. SIGKILL (signal 9) is handled by the kernel directly and always terminates the process.
