Shell – How to return a background task to be in the foreground

background-processjobsshell

I would like to know how to stop a running process after appending it with &.

For example, I would like to install software foo. Now, assume, foo has many dependancies, it takes an hour to finish. So, I do: yum install foo &. But I would like to stop that on-going process either by making it foreground (the actual premise of my question) so I can interrupt it, or through other methods if necessary.

Ctrl+C does not seem to stop this.

Best Answer

If the terminal you launched the command from is still open, you can get it back by running fg.

If it is not, identify the process ID by running ps aux | grep yum or just pgrep yum and then use kill PID. Or, if you know you only have one yum instance, run pkill yum.

Related Question