Run the command CTRL + Z to force the current process to be switched to the background and stop it.
1. resume the process (background)
(1) Use the command bg
Example:
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $./tcpserv01
* CTRL + Z is used here, And serv01 is stopped *
[1] + Stopped./tcpserv01
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $ bg
[1] +./tcpserv01 & * at this time, serv01 runs in the background *
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $
(2) What if I use CTRL + Z to stop several programs?
Example:
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $ jobs
[1]-Running./tcpserv01 &
[2] + Stopped./tcpcli01 127.0.0.1
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $ bg % 1
Bash: bg: Task 1 has been transferred to the background * run in the background *
2. Restore the process to the foreground
Example:
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $./tcpserv04
[1] + Stopped./tcpserv04
Zuii @ zuii-desktop :~ /Unp/tcpcliserv $ fg
./Tcpserv04
Summary:
(1) CTRL + Z stop the process and put it in the background
(2) jobs displays the currently paused Processes
(3) bg % N run the nth task in the background (there is a space before %)
(4) fg % N run the nth task on the foreground
Bg by default. If fg does not contain % N, the last process is operated!