A. Shell supports role control by using the following commands:
1. Command & run the process in the background
2. Jobs view the processes running in the background
3. FG % N bring the processes running in the background to the foreground
4. bg % N let the process n go to the background;
PS: "N" indicates the process number viewed by jobs.
B. Related commands
FG, BG, jobs, &, CTRL + Z are all related to system tasks. Although these commands are rarely used, they are also very practical.
I. & Most frequently used
This command is used at the end of a command and can be executed in the background.
II. CTRL + z
You can put a command that is being executed on the foreground in the background and pause it.
3. Jobs
View the number of commands currently running in the background
4. FG
Move 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
Pause a command in the background to continue execution.
If there are multiple commands in the background, you can use BG % jobnumber to call up the selected command. % jobnumber is the serial number (not PID) of the command being executed in the background found by the jobs command)
# Use shell commands in Linux to control jobs execution
The following commands can be used to manipulate process tasks:
PS: Lists processes running in the system;
Kill sends signals to one or more processes (often used to kill one process );
Jobs lists 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 the termination of a task is reported (that is, the task state is marked as terminated), shell deletes the process ID of the task from the List known in the Current Shell environment;
BG moves the process to the background );
FG moves the process to the foreground for running (foreground );
Transfer the job to the background for running
If you often work in x graphics, you may have the experience of running a GUI program through Terminal commands. The GUI is displayed, but your terminal remains in the same place, you cannot execute other commands in shell unless you disable the GUI program.