Ubuntu Common Command Process Management

Source: Internet
Author: User
Tags dashed line

What is a process
    • Program: Typically a binary program is placed in a storage medium (such as a hard disk, disc, floppy disk, tape, etc.), in the form of physical files.
    • Process: After the program is triggered, the performer's permissions and properties, program code and required data will be loaded into memory, the operating system and give the memory unit an identifier (PID), that is to say: The process is a running program.

    • Parent-child processes

[email protected]:~$ ps-lf S UID PID PPID C PRI NI ADDR SZ Wchan TTY TI ME CMD0 S 1000 "7261" 7253 0 0-7083 wait pts/0 00:00:00 bash0 T 1000 16097 "7261" 0 80 0-145 Signal pts/0 00:00:00 vim0 R 1000 17246 "7261" 0 0-3484-pts/0 00:00:00 ps//you can see that bash is the parent process PI D is 7261, and the ' ps ' command executed in this bash is the child process of bash. ' Wait ' represents the dashed line, and bash is asleep. F: Represents the process flag, which describes the permissions of the process. 4 means  "permission is Root", and  1 means  "Forked but didn ' t exec", 0 means  that  neither Flag applies. 0 always means  that  None of  the flags are set .//S: Indicates the underlying state: r-running S-sleep;t-stop;z-zombie;d-is not a fantasy sleep state, usually waiting for I/O. 
    • Fork and exec
      The process produces an identical child process through the parent process in a copy (fork), and the child process that is copied then executes the actual process in an exec manner, and eventually becomes the existence of a child process.

The system first to fork to copy a process with the same staging process, the process and the parent process is the only difference between the PID is different! However, this staging process will also have one more ppid parameter. Then the staging process begins to load the actual program to be executed in an exec manner, as described above, the new process is named QQQ, and the program code of the final child process becomes QQQ.

    • System or NETWORK service: a process that resides in memory

      • For file-related operations such as: Display file ls, new file touch, manage file rm/mkdir/cp/mv, Rights Management chmod/chown/passwd, the command triggered by the PID soon ended. Common file operation, the use of Ubuntu Common command file operation
      • A process that resides in memory becomes a service (daemon), such as the network online service Apache, named, Psotfix, and so on, when the program is executed it initiates a port that can be responsible for network snooping, providing connection requests from external clients (client).
    • Multi-user, multi-tasking environment for Linux

    • Multi-User: There can be multiple users on a Linux system, each user can have their own environment settings (~/.BASHRC), and an administrator (root), each user has a corresponding user group.
jack@ubuntu:~$ adduser username  // 添加用户
    • Multitasking: A process can be seen as a task, a point in time that only one process is running on the CPU. But thanks to the CPU's operation of up to several GHz, in the cup scheduling mechanism, even when many people at the same time to log on the system, it will feel that the entire host as if only for their own service. This is the multi-user, multi-tasking environment.

    • Seven basic terminal interfaces for multiple landing environments
      In Linux, 6 command-line interface landing windows and a graphical interface are provided by default. Use [ALT]+[F1]~[F7] to switch between different terminal interfaces, and each terminal interface can also be a different person (using AddUser to add users).

    • In the Ubuntu server version, the default login interface is tty1, using [ALT]+[F1]~[F6] to switch between different interface login Windows. No graphical interface is available and requires manual installation.
    • In Ubuntu Desktop Edition, the default login is the graphical interface, using [ALT]+[F1]~[F7] to switch different landing windows.

Special Process Management behavior : If the tty1 in the program is dead, you can switch to Tty2, through the PID, with the kill command to end the dead process, in return to Tty1

    • Job Management in bash environments (Job control)
      The "Parent-child process" was mentioned earlier, and when we landed Tty1 Bash we got a PID, and then the commands executed in bash were his child processes.
      When working in the command line interface, if you want to perform multiple tasks, such as copying a particularly large file while still using Vim to edit text, it is only a tty1 to switch to Tty2 and create a new bash process to work. When working with a non-graphical interface, you can edit the text by opening a new command line [Ctrl]+[alt]+[t].

How do I work in the Tty1 bash process? Cases:

jack@ubuntu:~$ cp file1 file2 &

Focus on & , put the current process in the background to run, still after the execution of this command, in this bash can still continue to do other operations, such as vim editing text.
Next we'll focus on job control.

Job Control Focus

Job Control: When we log in to the system to get the bash shell, we perform multiple behavior management at the same time under a single terminal. For example: After we landed bash, we wanted to copy it, do a data search, VIM programming, and implement it in a bash without switching between different TTY, without having to open different bash in the graphical interface.

//Used IntelliJ know that after running the ' idea.sh ' command, the relevant content will continue to be output, and bash will not be able to do anything else at this time, we can use the job control to put it in the background to run. There is also a need to use output redirection to put the output in other files and avoid running the output in the background to the current bash. //>: A file is created without files, and existing files are overwritten. #重定向 #//>>: The file is not present and the output is added to the file if it exists. Jack@ubuntu: ~$ idea.sh > Ideash. out&[1]15705Jack@ubuntu: ~$ jobs-l//view programs in the background[1]+15705Running idea.sh > Ideash. out&//Open vim Edit file again, [Ctrl] + [z] Pause programJack@ubuntu: ~$ vim Ideash. out[2]+ Stopped vim Ideash. outJack@ubuntu: ~$ jobs-l[1]-15705Running idea.sh > Ideash. out&[2]+16097Stopped vim Ideash. out//[1]: Indicates job number is 1//+: Represents a recent job that has been dropped to the background. -: Represents the second-to-last job that has been thrown into the background. And then the job doesn't show up.//15705: Representative PID//Running: Status of Work//idea.sh > Ideash.out &: Commands to executeJack@ubuntu: ~$ FG%2 //Return to Job 2 to continue with vim editing. Jack@ubuntu: ~$ BG%jobnumbers//Let the job in stop run in the background. //1: Similar to reload #signal #//9: Forced shutdown//15: Normal shutdown, default valueJack@ubuntu: ~$ Kill%1  //kill-signal%jobnumbers managing background ProcessesJack@ubuntu:~$ [919305] Warn-api.vfs.impl.local.filewatcher-watcher Terminated withExit code143^c[1]-Terminated idea.sh > Ideash. outJack@ubuntu: ~$ jobs[2]+ Stopped vim Ideash. out
    • Offline management
      The "backstage" in job control refers to a situation in which bash avoids [Ctrl] + [C] interrupts and is not behind the system. If the current bash finishes, other processes that are executing in bash will also end. Through nohup can reach the mission room to the system backstage.
jack@ubuntu:~$ // 默认输出到nohup.out,相当于nohup idea.sh & >> nohup.out
Process Management
>-l//显示当前进程>//显示系统所有进程>-signal//管理进程,signal同上,

Inevitably there is negligence, if you have questions please leave a message!

Ubuntu Common Command Process Management

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.