Linux program frontend background Switch

Source: Internet
Author: User

Linux program frontend background switch 1. When running commands on a Linux terminal, add the & symbol at the end of the command to allow the program to run Ubuntu $ "> root @ Ubuntu $. /tcpserv01 &

2. If the program is running on the foreground, you can use the CTRL + z option to pause the program, and then run the BG % [number] command to put the program in the background to run Ubuntu "> CAT @ Ubuntu :~ /UNP/unpv13e/tcpcliserv $./tcpserv01 ^ Z [1] + stopped./tcpserv01 cat @ Ubuntu :~ /UNP/unpv13e/tcpcliserv $ BG % 1 [1] +./tcpserv01 & CAT @ Ubuntu :~ /UNP/unpv13e/tcpcliserv $

3. For all running programs, run the jobs-l command to view cat @ Ubuntu :~ /UNP/unpv13e/tcpcliserv $ jobs-L [1] + 4524 running./tcpserv01 &

4. You can also run the command FG % [number] to drop a program to the foreground and run cat @ Ubuntu :~ /UNP/unpv13e/tcpcliserv $ FG % 1./tcpserv01

5. You can also directly terminate the program running in the background and run the kill command cat @ Ubuntu :~ /UNP/unpv13e/tcpcliserv $ kill % 1

Shell supports role control and has the following commands: 1. command & let the process run in the background 2. jobs: view the processes running in the background. 3. FG % N let the background running process n to the foreground 4. BG % N let process n go to the background; PS: "N" indicates the process number viewed by jobs.

B. the following turn: http://blog.chinaunix.net/u/1604/showart_1079559.html FG, BG, jobs, &, CTRL + Z are related to the system task, although now basically do not need to use these commands, but learned is also very practical. & This command is most often used at the end of a command. You can put this command in the background for execution 2. CTRL + Z can put a command that is being executed on the front-end to the background, and pause the three. Jobs: view the number of currently running commands in the background. FG transfers the commands in the background to the foreground to continue running. If there are multiple commands in the background, you can use FG % jobnumber to call up the selected command, % jobnumber is the serial number (not PID) of the command being executed in the background found through the jobs command)

5. BG pauses a command in the background and continues execution. If there are multiple commands in the background, you can call out the selected command with BG % jobnumber, % jobnumber is the serial number (not PID) of the command being executed in the background found through the jobs command)

# Use shell commands in Linux to control job jobs and execute the following commands to manipulate process tasks: PS: list processes running in the system; kill sends signals to one or more processes (often used to kill one process). Jobs list the status of started tasks in the Current Shell environment. If jobsid is not specified, the status information of all active tasks is displayed. If a task is terminated (that is, the task status is marked as terminated ), shell deletes the process ID of a task from the list of known shell environments; BG moves the process to the background for running; FG moves the process to the foreground for running (foreground ); transfer the job to the background. If you often work in x graphics, you may have the following experience: run a GUI program through Terminal commands, and the GUI is displayed, however, your terminal remains in the same place. You cannot execute other commands in shell unless you turn off the GUI program.

To enable the terminal to continue to accept commands after the program is executed, you can move the process to the background and run the program using the following command: # suppose you want to run xmms $ xmms & Open xmms in this way, the terminal prompt is returned. Currently, xmms is running in the background. However, if you forget to use "&" when running the program and do not want to execute it again, you can use Ctrl + Z to suspend the program first, then, press the BG command to continue running the program in the background.

Concept: if the current task has two backend task numbers: [1], [2]. If the first background task is successfully executed, the second background task is still in progress, the current task automatically becomes a background task with the background Task Number "[2. So we can conclude that the current task will change. When you enter commands such as "FG", "BG", and "stop", if no quotation marks are added, all changes are made to the current task.

You can view jobs that are being executed by running jobs or PS commands. the result of running the jobs command. + indicates a current job. The minus table is a job after the current job. The jobs-L option displays the PID of all tasks, jobs can be in the running, stopped, and terminated state. However, if the task is terminated (kill), the shell deletes the process ID of the task from the List known in the Current Shell environment. That is, the jobs command displays information about the tasks that are running or suspended in the background in the Current Shell environment. The pending background processes: run the Stop command in Solaris, run the jobs command to view the job number (assuming num) and run Stop % num. in RedHat, the Stop command does not exist. You can run the command kill-Stop PID to suspend the process; when you want to re-execute the currently suspended job, change the status of the suspended job from stopped to runnin through BG % num. G, which is still executed in the background. If you want to run the command on the foreground, Execute Command FG % num; suspend the foreground process: Ctrl + z; terminate the background process of the process: method 1: run the jobs command to view the job number (assuming num), and then run kill % num. Method 2: run the ps command to view the job process number (PID, assuming PID ), run the kill PID command to terminate the front-end process: Ctrl + C kill. In addition to terminating the process, kill can send other signals to the process. Use kill-L to check the signals supported by kill.

Sigterm is a signal sent by kill without parameters. It means that the process must be terminated, but whether the process is executed or not depends on whether the process is supported. If the process has not been terminated, you can use the kill-sigkill PID, Which is terminated by the kernel. The process cannot listen to this signal.

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.