Basics of Linux learning (7) [1. Process definition 2. ps command 3. Process priority 4. Front and back calls of processes in the environment 5. Process signals 6. User login audit 7. top command]

1. Process Definition
A process is the unfinished work of the cpu


   ps

    a ##All processes about the current environment


    x| -A ##All processes


    f ## show process affiliation


    e ##Display the details of the process call environment tool


    l ##Long list display process details


    u ##Display user information of the process


    -a ##Display shell foreground processes running commands, but do not guarantee shell itself

ps ax -o %cpu,%mem,user,group,comm,nice,pid,stat Specifies to display some information about the process

%cpu ##Display process cpu load

%mem ##Display process memory load


user ##Process user
group ##Process group
comm ##Process name
nice ##Process priority
pid ##Process id

stat ##Process status



 Information displayed in stat
S Process status
l Lock space in memory
N Low
priority < high priority
+ foreground running

s top-level process
+ positive order
- reverse order

3. Process priority
1. The priority range of the process

-20~19

priority view

ps ax -o pid,nice,comm

3. Specify a priority to start the process
nice -n priority number process name

nice -n 5 gedit & start gedit and specify program priority as 5



4. Change the process priority
reince -n priority number process pid

renice -n 5 4639 ##Change the priority of the 4639 process to 5


4. The foreground and background calls of the process in the environment

jobs View the processes that have been pushed into the background of the environment


ctrl+z put the process occupying the terminal into the background

fg jobsnum brings the background process back to the foreground

bg jobsnum suspend the running process in the background

comm & let the command run directly in the background


5. Process signal

1. Common signal level
1 Process reloading configuration
2 Delete process data in memory
3 Delete mouse data in memory
9 Force end a single process (cannot be blocked)
15 Close process normally (may be blocked)    
18 Running suspended process

19 ##Pause a process (cannot be blocked)

20 ## put the process into the background (can be blocked)

man 7 signal ##View signal details


****kill - signal process pid


killall -signal process name

pkill -u student    

-signal SIGHUP Terminate the process Terminal line hangs up
SIGINT Terminate the process Interrupt the process
SIGQUIT Create a CORE file to terminate the process and generate a core file
SIGILL Create a CORE file Illegal instruction
SIGTRAP Create a CORE file Trace trap
SIGBUS Create a CORE file Bus error
SIGSEGV Create CORE file segment illegal error
SIGFPE Create CORE file Floating point exception
SIGIOT Create CORE file Execute I/O trap
SIGKILL Terminate process Kill process
SIGPIPE Terminate process Write data to a pipe with no reading process
SIGALARM Terminate process Timer expires
SIGTERM Terminate process Software termination signal
SIGSTOP Stop process Stop signal from non-terminal
SIGTSTP Stop process Stop signal from terminal
SIGCONT Ignore signal Continue to execute a stopped process
SIGURG Ignore signal I/O emergency signal
SIGIO Ignore signal I/O can be performed on descriptor
SIGCHLD Ignore Signals notify the parent process when the child process stops or exits
SIGTTOU Stop the process The background process writes
the terminal SIGTTIN Stops the process Signal 1 SIGUSR2 Terminate the process User-defined signal 2 SIGVTALRM Terminate the process Virtual timer expires 1) SIGHUP This signal is issued when the user terminal connection (normal or abnormal) ends, usually when the terminal's control process ends, notifying the same session 2) SIGINT program termination (interrupt) signal, issued when the user types the INTR character (usually Ctrl-C) 3) SIGQUIT is similar to SIGINT, but consists of the QUIT character (usually Ctrl-) to control. The core file is generated when the process exits on receipt of SIGQUIT, which is similar to a program error signal in . 4) SIGILL An illegal instruction was executed. Usually because the executable file itself appears Error, or attempt to execute data segment. This signal may also be generated on stack overflow. 5)






















SIGTRAP is generated by a breakpoint instruction or other trap instructions. Used by the debugger.
6)
SIGABRT is generated when the program itself finds an error and calls abort.
6)
SIGIOT is generated by the iot instruction on the PDP-11, and is the same as SIGABRT on other machines.
7 )
SIGBUS Illegal address, including memory address alignment errors. eg: accessing a four
- integer whose address is not a multiple of 4.
8)
SIGFPE is issued when a fatal arithmetic operation error occurs. Not only floating point Arithmetic errors, including
overflow and division by 0, and all other arithmetic errors.
9)
SIGKILL is used to end the program immediately. This signal cannot be blocked, handled or ignored.
10)
SIGUSR1 is reserved for the user.
11)
SIGSEGV Attempt to access memory not allocated to itself, or attempt to write data to a memory address that does not have write permission.
12)
SIGUSR2 is left to the user.
13)
SIGPIPE Broken pipe
14)
SIGALRM Clock timing signal, which calculates the actual time or clock time. The alarm function uses this
signal .
15)
SIGTERM program end (terminate) signal, which is different from SIGKILL in that this signal can be blocked and
Processing. Usually used to ask the program to exit normally. The shell command kill generates
this .
17)
SIGCHLD When the child process ends, the parent process will receive this signal.
18)
SIGCONT Let a stopped process continue to execute . This signal cannot be blocked.
A to let the program do specific
work when it changes from the stopped state to continuing execution. For example, redisplay the prompt
19)
SIGSTOP stops the execution of the process. Note that it and terminate and The difference between interrupt:
the process has not ended, just suspend execution. This signal cannot be blocked, processed or ignored.
20)
SIGTSTP stops the running of the process, but the signal can be handled and ignored. When the user types the SUSP character
(usually Ctrl -Z) Issue this signal
21)
SIGTTIN When a background job wants to read data from the user terminal, all processes in the job will receive the SIGTTIN
signal. By default these processes will stop executing.
22)
SIGTTOU is similar to SIGTTIN, but in Received when writing to the terminal (or changing the terminal mode).
23)
SIGURG is generated when "urgent" data or out-of-band data arrives on the socket.
24)
SIGXCPU CPU time resource limit exceeded. This limit can be read by getrlimit/setrlimit take/
change
25)
SIGXFSZ exceeds the file size resource limit.
26)
SIGVTALRM virtual clock signal. Similar to SIGALRM, but calculates the CPU time occupied by the process.
27)
SIGPROF is similar to SIGALRM/SIGVTALRM, but includes the CPU time used by the process and the system The
time .
28)
SIGWINCH is issued when the window size changes.
29)
SIGIO The file descriptor is ready for input/output operations.
30)
SIGPWR Power failure

There are two signals to stop the process: SIGTERM and SIGKILL. SIGTERM is more friendly, the process can catch this signal and close the program according to your needs. You can end open log files and complete tasks in progress before closing the program. In some cases, the process can ignore this SIGTERM signal if the process is doing work and cannot be interrupted.

Processes cannot ignore SIGKILL signals. It's an "I don't care what you're doing, stop now" signal. If you send a SIGKILL signal to a process, Linux stops the process there



6. User login audit record

1.
w View the current users who use the system

w -f -f View where to use



2.
last View user login success history
3.

lastb View the history of unsuccessful user logins


7.top command
top ##Monitoring system load Tools
s : Modify the process refresh interval
m : Sort by memory occupancy
c : Sort by cpu occupancy
u : Enter the user name later to view all processes initiated by the user
k : followed by the pid of the process to be used, and the initiated signal (eg: 9, 15, 20) to
initiate a signal to a process
q : exit the process and view the interface
h : display the help of the top command



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325447429&siteId=291194637