Linux operation and Maintenance management UNIT7

Source: Internet
Author: User
Tags arithmetic




##################
# # # Process Definition # # #
##################
Whenever an event is triggered, the system defines it as a process and gives the process an ID, called the PID.
Process is the work that the CPU does not complete
*) distinguish procedures and processes:
Program----> is usually placed in the storage medium (such as hard disk, CD-ROM, floppy disk, tape, etc.), in the form of a physical file;
After the process----> 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), it can be said that the process is a running program.

##############
# # # PS Command # # #
##############
PS a #显示当前环境的所有进程
PS x #与当前环境无关的所有进程
PS F #显示进程的从属关系
PS e #显示进程调用环境工具的详细信息
PS L #长列表显示进程的详细信息
PS u #显示进程的用户信息

[[email protected] desktop]$ ps -lf s    uid   pid  ppid  c pri  ni addr sz  wchan  tty          time cmd0 s   1000  5084  3655  0  80   0 -  29071 wait   pts/2    00:00:00 bash0 r  1000   5352  5084  0  80   0 - 34343 -       pts/2    00:00:00 ps*) Bash's PID is the same as PS's ppid because the PS process is generated with bash 

The

PS command can specify certain information to display the process, and sort by information
PS a|x-o%cpu,%mem,comm--sort <+%cpu>
a|x    # A displays all processes related to the current environment, x displays all processes that are not relevant to the current environment
-o     #指定显示进程的某些信息:%CPU---Displays the CPU load of the process;%mem---Show the process memory load User---Show process users, group---Show process groups, Comm---show process name; nice---show process priority; PID---show process ID
--sort     #指定显示进程信息排序: <+%cpu>---+ indicates a positive order, which is reversed;%cpu refers to sorting by CPU load or using%MEM to sort by memory load

[[email protected] desktop]$ ps a  pid tty       STAT   TIME COMMAND 2557 tty1     Ssl+    0:39 /usr/bin/Xorg :0 -background none -noreset -aud 3663  pts/0    ss     0:00 /bin/bash 4505 pts/0     S+     0:00 vim unit7 4511 pts/1     ss     0:00 /bin/bash 4731 pts/1    s+      0:00 vim unit7 5084 pts/2    Ss      0:00 bash 6148 pts/2    R+      0:00 ps a[[email protected] desktop]$ ps a -o %cpu,%mem,nice,pid %cpu %mem  ni   PID 0.1  0.9   0  2557 0.0  0.0    0  3663 0.0  0.1   0  4505 0.0   0.0   0  4511 0.0  0.1   0  4731 0.0   0.0   0  5084 0.0  0.0   0  6152[ [Email protected] desktop]$ ps a -o %cpu,%mem,nice,pid --sort +%cpu  %CPU %MEM  NI   PID 0.0  0.0   0   3663 0.0  0.1   0  4505 0.0  0.0   0   4511 0.0  0.1   0  4731 0.0  0.0    0  5084 0.0  0.0   0  6156 0.1   0.9   0  2557 

####################
# # # Process Priority # # #
####################
1, Process priority range: -20~19
2, Priority view: PS Ax-o Pid,nice,comm

[[Email protected] desktop]$ PS a-o pid,nice,comm pid NI COMMAND 2557 0 Xorg 3663 0 Bash 4505 0 vim 4511 0 bash 4731 0 vim 5084 0 bash 6358 0 ps*) View only the priority of all processes in the current environment, nice represents the process priority

3, specify a priority to open the process: Nice-n priority number Process name

[[email protected] desktop]$ nice -n 5 vim &[1] 6394[[email  Protected] desktop]$ ps a -o pid,nice,comm  pid  ni command  2557   0 xorg 3663   0 bash 4505   0  vim 4511   0 bash 4731   0 vim 5084   &NBSP;0&NBSP;BASH&NBSP;6394&NBSP;&NBSP;&NBSP;5&NBSP;VIM&NBSP;6412&NBSP;&NBSP;&NBSP;0&NBSP;PS4, change process priority: Renice  -n  Priority Digital   process Pid[[email protected] desktop]$ ps a -o pid,nice,comm   pid  ni command 2557   0 xorg 3663   0  bash 4505   0 vim 4511   0 bash 4731    0 vim 5084   0 bash 6394   5 vim 6412    0 ps[[email protected] desktop]$ renice -n 5 50845084  (Process ID)   Old priority 0, new priority 5[[email protected] desktop]$ ps a  -o pid,nice,comm  pid  ni command 2557   0 xorg  3663   0 bash 4505   0 vim 4511   0  bash 4731   0 vim 5084   5 bash 6394    5 vim 6442   5 ps[[email protected] desktop]$ ps -lf  S   UID   PID  PPID  C PRI  NI  addr sz wchan  tty          time  Cmd0 s  1000  5084  3655  0  85   5  - 29097 wait   pts/2    00:00:00 bash0 t  1000  6394   5084  0  85   5 - 37197 signal pts/2     00:00:00 vim0 R  1000  6618  5084  0   85   5 - 34343 -      pts/2     00:00:00 ps*) Note: When you change the priority of 5084, the priority of 6442 is also changed. This is because the ppid of PS is generated by the PID of Bash

##############################
# # # # # # # # # # # # of processes in environment
##############################
Jobs #查看被打入环境后台的进程
CTRL + Z #把占用终端的进程打入后台
FG #把后台进程调回前台
BG #把后台暂停的进程运行
Comm & #让命令直接在后台运行

################
# # # process Signal # # #
################
Common signal levels:
1---process reload configuration
2---Delete the process's in-memory data
3---Delete the mouse in-memory data
9---Forcibly end a single process
---normal shutdown process
---Running a paused process
---pause a process
---the process into the background
Man 7 signal #查看信号详细信息

Kill-Signal Process PID
Killall-Signal Process name
Pkill-u Username-Signal
*) commonly used kill-9 PID to forcibly terminate a process

SIGHUP terminating process terminal line hang-off
SIGINT terminating process Interrupt process
Sigquit establish core file termination process, and generate core file
Sigill Creating a core file illegal directive
SIGTRAP build core file tracking self-trapping
Sigbus establishing a core file bus error
SIGSEGV creating core file Segment Illegal error
SIGFPE creating a core file floating point exception
Sigiot creating a core file to perform I/O self-trapping
SIGKILL Terminate process Kill process
Sigpipe terminating a process writing data to a pipeline that does not have a read process
Sigalarm Terminating process timer to
SIGTERM terminating process software termination signal
SIGSTOP stop signal stop process non-terminal
SIGTSTP stop signal to stop the process terminal
Sigcont ignore signal continue execution of a stopped process
Sigurg ignoring signal I/O emergency signal
SIGIO ignoring the signal descriptor can be I/O
SIGCHLD Ignore signal Notify parent process when child process stops or exits
Sigttou Stop process background process write terminal
Sigttin Stop process background process read Terminal
SIGXGPU terminating process CPU time-out
SIGXFSZ termination process file length too long
Sigwinch ignoring signal window size changes
SIGPROF terminating process statistics distribution graph with timer to time
SIGUSR1 terminating a process user-defined signal 1
SIGUSR2 terminating a process user-defined signal 2
SIGVTALRM terminating process virtual timer to time

1) SIGHUP
This signal is issued at the end of the user terminal connection (normal or abnormal), usually in the terminal control
At the end of the process, notify each job in the same session, and the control terminal
is no longer associated.
2) SIGINT
program termination (interrupt) signal, which is emitted when the user types Intr characters (usually ctrl-c)
3)
Sigquit and SIGINT are similar, but are controlled by the Quit character (usually ctrl). Process in response to receipt
Sigquit exit will produce a core file, in this sense similar to a program error letter
No..
4)
Sigill executed an illegal instruction. This is usually due to an error in the executable file itself or an attempt to execute
Data segment. This signal can also be generated when a stack overflows.
5)
The SIGTRAP is generated by a breakpoint instruction or other trap instruction. Used by debugger.
6)
The SIGABRT program itself discovers the error and calls abort when it is generated.
6)
The Sigiot is generated on the PDP-11 by the IoT instructions, on other machines and SIGABRT.
7)
Sigbus illegal address, including memory address alignment (alignment) error. Eg: access to a four word length
Integer, but its address is not a multiple of 4.
8)
SIGFPE is emitted when a fatal arithmetic operation error occurs. Includes not only floating-point arithmetic errors, but also overflow
The sum of the divisor is 0 and all other arithmetic errors.
9)
The SIGKILL is used to immediately end the run of the program. This signal cannot be blocked, processed and ignored.
10)
SIGUSR1 left for users to use
11)
SIGSEGV attempts to access memory that is not allocated to itself, or attempts to write data to a memory address that does not have write permissions.
12)
SIGUSR2 left for users to use
13)
Sigpipe Broken Pipe
14)
The SIGALRM clock timing signal calculates the actual time or clock time. The alarm function uses the
Signal.
15)
SIGTERM program End (terminate) signal, unlike Sigkill, the signal can be blocked and
Processing. Usually used to ask the program to exit normally. The shell command kill default produces this
A signal.
17)
At the end of the SIGCHLD child process, the parent process receives this signal.
18)
Sigcont let a stop (stopped) process continue execution. This signal cannot be blocked. can be used
A handler that allows the program to complete a specific application when the stopped state changes to continue execution.
Job. For example, to re-display the prompt
19)
SIGSTOP the execution of the Stop (stopped) process. Notice the difference between it and terminate and interrupt:
The process is not over yet, just pausing execution. This signal cannot be blocked, processed or ignored.
20)
SIGTSTP stops the process from running, but the signal can be processed and ignored. When a user types Susp characters
(usually ctrl-z) sends this signal
21)
Sigttin when a background job wants to read data from a user terminal, all processes in that job receive Sigttin
Signal. By default, these processes stop executing.
22)
Sigttou is similar to Sigttin, but is received when writing a terminal (or modifying terminal mode).
23)
Sigurg is generated when "emergency" data or Out-of-band data arrives at the socket.
24)
SIGXCPU exceeds CPU time resource limit. This limit can be read by Getrlimit/setrlimit/
Change
25)
Sigxfsz exceeds the file size resource limit.
26)
SIGVTALRM virtual clock signal. is similar to SIGALRM, but calculates the CPU time that is consumed by the process.
27)
Sigprof is similar to SIGALRM/SIGVTALRM, but includes the CPU time used by the process and the system call
Time.
28)
Sigwinch when the window size changes.
29)
The SIGIO file descriptor is ready to start the input/output operation.
60L
SIGPWR Power Failure

There are two signals to stop a process: Sigterm and Sigkill.
Sigterm is friendly and the process captures the signal and shuts down the program according to your needs. Before you close the program, you can end the open record file and complete the task you are doing. In some cases, if the process is working and cannot be interrupted, the process can ignore the sigterm signal.
For Sigkill signals, the process cannot be ignored. This is a "I don't care what you are doing, stop immediately" signal. If you send a sigkill signal to the process, Linux will stop the process there

####################
# # # User Login Audit # # #
####################
W #查看使用系统的当前用户有哪些
W-f #查看使用地点
Last #查看用户登陆成功历史
Lastb #查看用户登陆未成功历史

###############
# # # Top Command # # #
###############
Top #监控系统负载工具
Http://www.jb51.net/LINUXjishu/34604.html

This article is from the "12449513" blog, please be sure to keep this source http://12459513.blog.51cto.com/12449513/1924293

Linux operation and Maintenance management UNIT7

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.