How can I resume a stopped job in Linux?

This is actually a fairly normal work flow for Vim, if you want to keep you commands in your bash history, then you hit Ctrl-z type your commands and then resume. Obviously you can run commands without leaving Vim via the :! ed command

Commented Jul 11, 2018 at 2:32

6 Answers 6

The command fg is what you want to use. You can also give it a job number if there are more than one stopped jobs.

answered Apr 8, 2011 at 9:39 5,516 1 1 gold badge 17 17 silver badges 8 8 bronze badges for reference, fg is "foreground". You can also continue the job in the background with "bg". Commented Apr 8, 2011 at 11:05 You can also give it a job number --> Simply doing fg 1 doesn't work, the syntax is fg %1 Commented May 4, 2023 at 7:50

The general job control commands in Linux are:

That's pretty much all of them. Note the % infront of the job number in the commands - this is what tells kill you're talking about jobs and not processes.

811 1 1 gold badge 9 9 silver badges 15 15 bronze badges answered Apr 8, 2011 at 11:55 32.6k 4 4 gold badges 63 63 silver badges 81 81 bronze badges I avoid "kill %1" because mistyping it as "kill 1" is really really bad :) Commented Apr 8, 2011 at 14:05 @barrycarter That's very true. I usually do an fg and a Ctrl-C ;) Commented Apr 8, 2011 at 14:08 @barry: Which is why init in Upstart ignores SIG by default. Commented Apr 19, 2011 at 2:26 And, of course, "never run as root" ;) Commented Apr 19, 2011 at 3:04

Why use "%" character. Is it required to be prepended before the job number or Is it a unix convention to specify the int type ?

Commented Feb 28, 2020 at 5:03

You can also type % ; i.e., you hit Ctrl-Z in emacs, then you can type %emacs in the console and bring it back to the foreground.

answered Aug 26, 2013 at 21:04 551 4 4 silver badges 2 2 bronze badges Very good to know Commented Oct 22, 2015 at 21:42

Just to add to the other answers, bash lets you skip the fg if you specify a job number.

For example, these are equivalent and resume the latest job:

% %% fg fg % 

These resume job #4:

%4 fg 4 
answered Apr 8, 2011 at 14:03 grawity_u1686 grawity_u1686 470k 66 66 gold badges 987 987 silver badges 1.1k 1.1k bronze badges While this is kind of cool, I still find it easier to type fg than % . Commented Oct 10, 2014 at 17:10

% is awesome, thanks! As a touch-typist, I find fg very irritating (same finger). But then, so is cd .

Commented Apr 15, 2015 at 13:45 And you can start it in the background with either bg % or just % & . Commented Aug 16, 2016 at 18:43

in my case when i tried to use fg i see the stopped process appears and disappears quickly and just succeeded to restore it.

Commented Jun 25, 2019 at 12:54

If you didn't launch it from current terminal, use ps aux | grep to find the process number (pid), then resume it with:

kill -SIGCONT

(Despite the name, kill is simply a tool to send a signal to the process, allowing processes to communicate with each other. A "kill signal" is only one of many standard signals.)

Bonus tip: wrap the first character of the process name with [] to prevent the grep command itself appearing in the results. e.g. to find emacs process, use ps aux | grep [e]macs

answered Feb 4, 2016 at 19:49 1,073 1 1 gold badge 11 11 silver badges 16 16 bronze badges This also works if you disown a stopped process Commented Dec 6, 2017 at 1:21 can you also get access to its input/output as it happens when you say fg ? Commented Oct 2, 2018 at 9:39 This is a much more flexible approach than working with job number. Thumbs up. Commented Feb 14, 2019 at 22:55 Shorter still: kill -SIGCONT $(pgrep ) Commented Feb 23, 2023 at 17:44

For anybody who wants to continue all suspended processes.

I don't know how but I achieved several times to completely lock my screen. When I check the processes there are dozens that are suspended. So I continued all processes to unlock my screen.

Switch to text console with Ctrl-Alt-F3 or similar. Log in, then issue:

ps ax|grep " T"| awk '' |grep -v PID | xargs echo kill -SIGCONT 

Output is something like this:

kill -SIGCONT 214191 334813 

Either remove echo , cut & paste or pipe the output through bash to actually execute it.