builtin

fg

Resume a known job in the foreground. In a fresh interactive terminal, run sleep 10 in the background, inspect jobs, then use fg with its actual job number. Terminal execution is not locally tested.

Formal Syntax & Structure

bash syntaxbash
fg [jobspec]

Parameters & Attributes

NameTypeDescription
jobspecjob identifierActual job in this shell.

Return Value

exit status

fg returns the foreground command status or a failure; bg returns zero on successful resumption, nonzero on error.

Working Example

Example Snippetbash
sleep 10 &jobs# In a fresh shell, if the displayed job is 1:fg %1
Bash Reference