Linux process management and related commands

Source: Internet
Author: User

Some concept terminals

Also called terminal equipment, early because the computer is more expensive, so a host will have multiple terminals, these terminals themselves do not have the computing power, only assume the input and output of information work, computing and processing by the host to complete.
Now the PC can also run the terminal emulator to emulate a terminal to work.
With the development of computer, mobile terminal also has a wide range of applications, not only can be input and output of the work, but also to perform certain operations, to achieve some of the system's functions.

Permissions for the process

See Linux under Process permissions analysis
The general process has 3 uid, RUID (real user ID), EUID (valid user ID), SUID (save user ID)
setuid (UID)
When you are root , you can use this function to turn yourself into a user with ID UID and cannot return to root. That is, when you are root, you use this function and your ruid,euid,suid are changed.
Seteuid (Euid)
But when you use this function, your ruid,suid is still 0 and the change is just your euid. This way you can go back to being root.

There is also a set User ID (set UID), which is the third field in the 9 permissions of the corresponding file. If a binary file setting sets the user ID, then if the file owner does not have the X permission for the file, and the file is executed, then the euid of the process generated at execution is the owner of the file .

Inheritance of permissions
When using the fork child process, the child process all inherits the parent process four UID, and the parent process UID is the same; when using the Exec series function, the suid is set to Euid.

Example Description:
For example, when a different user gets a bash shell when they log on, the resulting shell is different. A shell with different permissions is generated based on the user's identity information.

System or NETWORK Service

A process that resides in memory. Also called Daemon.

Work Management

every job is a subroutine for the current bash when it comes to work management. That is to say, different terminals can not be managed with each other. Each bash can only manage its own work and not manage other bash's work.

Concept

Front Desk: The environment in which the prompt character allows you to operate
Backstage: Carry your environment, the work here is not to be interrupted by CTRL + C, that is, you can not interact with the background of the work interaction.

Job Control management

status of the job in the background:
In the background of the work, his state is generally stop,running.

How to put a job into the background processing
1.
You can add & to the end of the instruction to get the work done in the background.
Like what:

Attention
[1] 8400
Here 1 is the job ID to identify a job.
8400 This is the PID of the process corresponding to this work

2.
For the work you are currently working on, you can use Ctrl + Z to put your current work in the background.

Jobs command

use:
Observe the status of the job in the background now

Watch this.
[1]-10314
[2]+ 10833

+: Represents the job ID that was recently put into the background
-: The last job ID to be put in the background

FG directive

use:
Put the backstage work to the front desk.

%jobID
BG directive

use:
Make the work in the context of the State into work. Because there are jobs in the background is stopped, we can use this command to let you run up.

%jobID
Manage Job offline

Note that the job in the background is in terminal mode, not in the background of the system. Even if we are connected remotely to a Linux host, when we go offline, the work in the background will be interrupted. So in order to avoid this situation, we can use the NOHUP directive.

nohup[指令与参数]/* 将指令放到系统后台去 */nohup[指令与参数]   /* 将指令放在前台中执行 */
Process Management Process Observation instructions

PS Instruction

Example:

-l/* 只是看自己bash中的任务 */


F:process flag, which describes the summary permissions for this process.

    • If 4 indicates that the process has permission to root
    • If 1 indicates that this child process uses only fork and does not perform exec

S: Indicates the state of the process, mainly

    • R: Run
    • S: Sleep, can be awakened
    • D: Sleep that cannot be awakened
    • T: Stop
    • Z: Zombie Status

Uid/pid/ppid

C:CPU usage rate in percent

Pri/ni: Priority

PRI (new) = PRI (old) + Nice
Lower PRI indicates higher priority.

Addr/sz/wchan:

    • ADDR: Indicates which part of the process is in memory
    • SZ: How much memory was used to represent this process
    • Wchan: Indicates whether the current process is running

TTY: The location of the login's terminal, if Remote (pts/n)

Time: CPU times that are used off

CMD: What is the command that caused this process to trigger?

aux

Top Command
Transformation of the Dynamic Observer program

Example:

The first row (top) displays the following information, respectively:

    • Current time
    • The time it takes to boot to the current
    • Number of users who have logged on to the system
    • The system has an average load of 1, 5, 15 minutes.

The second row (Tasks) displays the following information:
The total amount of the current process, and what are their respective states

The third line (Cpus) shows the overall load of the CPU

Line four and line fifth: represents the current use of physical and virtual memory.

Line Six

Pstree
Form a tree-like process diagram.

Management of processes

Processes can be controlled from one another. You can send a signal by using the KILL command.

kill -signal PIDkillall -signal 指令名称
Process priority

Nice command

command

-N: followed by a number, the range of values -20~19
Note that the average user can only adjust the nice value of their own process, the range is 0~19, that is, only the priority of their own process is lowered.
Command: Because executing a command is when a child process is started, nice here is the equivalent of setting the Nice value for the child process.

Renice command

reniec[number]PID

The nice value of the tuning PID is number

Linux process management and related commands

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.