Multi-task in Linux Console

Source: Internet
Author: User
Multi-task in the Linux console-general Linux technology-Linux technology and application information. The following is a detailed description. Using the Linux console is also very efficient for some work. The Linux console supports multiple tasks. For the desktop environment, you can open multiple virtual terminals. On the Character interface, you can also log on to multiple virtual terminals (through Alt + F1, F2 ......) Run multiple programs. In fact, you can easily manage multiple tasks by using only one terminal.

When executing a command, add "&" to the end of the command name to run the command in the background. In this case, you can run the next command without waiting for the execution to complete. Background programs cannot accept keyboard input. For example, start the vi editor and run it in the background:

Albert @ albert-laptop :~ $ Vi &
[1] 10470

The jobs command is used to obtain the task list of the current terminal:

Albert @ albert-laptop :~ $ Jobs
[1] + Stopped vi

The 1 in the preceding square brackets is the task number, which is different from the process ID (PID. Of course, the vi running in the background is useless. vi cannot get the keyboard command, so it is in the Stopped status. To pull a background program to the foreground, use the fb % task number:

Albert @ albert-laptop :~ $ Fg % 1

In this way, the task numbered 1 is moved to the foreground for running.

How can I implement a program that runs at the front end but finds that the running time is too long? Press Ctrl + Z to Stop the current process so that bash can take over the standard input and output to continue receiving the next command entered by the user. But the suspended process is not running. In this case, run the jobs command to check its number, and then use

Bg % task id

Put it in the background to continue running. Fg and bg are two functional commands.

These functions are convenient for writing programs on the Character interface using vi. You can press Ctrl + Z in the vi editor to temporarily exit vi, execute some commands in bash, and then use the fg command to pull vi back to the foreground for further editing, it is very convenient for modification-testing.

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.