Linux Ctrl + z usage

Source: Internet
Author: User
Suppose you find it takes a long time to run a program on the front end, but you need to do other things, you can use
CTRL-Z, terminate the program, and then you can see the system prompt:
[1] + stopped/root/bin/rsync. Sh
Then we can schedule the program to the background for execution: (the number following BG is the job number)
# BG 1
[1] +/root/bin/rsync. Sh &
Run the jobs command to view running tasks:
# Jobs
[1] + running/root/bin/rsync. Sh &
If you want to call it back to the foreground, you can use
# FG 1
/Root/bin/rsync. Sh
In this way, you can only wait for this task to be completed on the console.
& Drop the command to the background for execution
[CTRL] + Z: Throw the foreground task to the background and pause
Jobs view the working status of the background
FG % jobnumber: Get the background task to the foreground for processing
BG % jobnumber put the task to the background for processing
Kill tasks in the management background
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.