Search code examples
linuxbashjobs

Foreground a bash command with & at the end


How could one foreground a bash command in Linux terminal such as

sleep 100 &

Solution

  • jobs will show you all the running jobs. You can then use the fg %<job number> command to bring a specific job to the foreground. E.g.:

    $ sleep 100 &
    [1] 19480
    $ jobs
    [1]+  Running                 sleep 100 &
    $ fg %1