linux process

First, the definition of a process: a process is the work that the cpu has not completed

2. ps command

1. ps
    a ##All processes about the current environment
    x| -A ##All processes
    f ##Display process affiliation
    e ##Display the detailed information of the process calling environment tool
    l ##Long list display the detailed information of the process
    u # #Display the user information of the process

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

Generally use ps aux to query the information we want to know


ps ax -o %cpu,%mem,user,group,comm,nice,pid,stat ##Specify 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 e ##process priority
pid ##process id

stat ##Process status

(Information displayed in stat
S ##Process status
l ##There is lock space in memory
N ##Priority low
< ##Priority high
+ ##Foreground running

s ## top-level process)

  ps ax -o %cpu,comm --sort <+|-%cpu > <+|-%mem> ##Sort by process information
+ ##positive order-
##reverse order
%cpu ##cpu load sorting

%mem ##Memory load

Third, the priority of the process (nice)

1. The priority range of the process is -20 to 19 (the lower the value, the higher the priority)

2. Priority view

ps ax -o pid,nice,comm


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

renice -n +5 5 ##Change the priority of the process whose pid is 5 to +5

Fourth, the front and background calls of the process in the environment

View the command jobs to view the processes that are pushed into the background

ctrl+z ##Enter the process occupying the terminal into the background
fg jobsnum ##Call the background process back to the foreground
bg jobsnum ##Run the suspended process in the
background comm & ##Let the command run directly in the background

Five, process signal

1. Common signal level
1 ##Process reload configuration
2 ##Delete process data in memory
3 ##Delete mouse data in memory
9 ##Forcibly end a single process (cannot be blocked)
15 ##Close the process normally (may be blocked)    
18 ##run a suspended process
19 ##suspend 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 process name

(The picture above has demonstrated the use of the kill command)

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 a CORE file Segment illegal error
SIGFPE Create CORE file Floating point exception
SIGIOT Create CORE file Perform I/O trap
SIGKILL Terminate process Kill process
SIGPIPE Terminate process Write data to a pipe that has no reading process
SIGALARM Terminate process Timer expires
SIGTERM Terminate process Software terminate signal
SIGSTOP Stop process Stop signal from non-terminal
SIGTSTP Stop process Stop signal from terminal
SIGCONT Ignore signal Continue execution of a stopped process
SIGURG Ignore signal I/O panic signal
SIGIO Ignore signal I/O can be done on descriptor
SIGCHLD Ignore signal when child process stops or Notify the parent process
with SIGTTOU when exiting, stop the process, and write the terminal in the background process
SIGTTIN Stop the process Background process reading terminal
SIGXGPU Terminate the process CPU timeout
SIGXFSZ Terminate the process The file length is too long
SIGWINCH Ignore the signal Window size changes
SIGPROF Terminate the process Statistical distribution graph uses the timer to
expire SIGUSR1 Terminate the process User-defined signal 1
SIGUSR2 Terminate the process User-defined Signal 2
SIGVTALRM terminates the process. When the virtual timer expires

1) SIGHUP
This signal is issued when the user terminal connection (normal or abnormal) ends, usually when the terminal
control process ends, notifying each job in the same session, then They are
no longer .
2) SIGINT
program termination (interrupt) signal, issued when the user types the INTR character (usually Ctrl-C)
3)
SIGQUIT is similar to SIGINT, but is signaled by the QUIT character (usually Ctrl-) Control. The core file is generated when the process exits on receipt of
SIGQUIT, in the sense that it is similar to a program error
signal .
4)
SIGILL An illegal instruction was executed. Usually because of an error in the executable itself, or an attempt to execute a
data segment . This signal may also be generated when the stack overflows.
5)
SIGTRAP is generated by breakpoint instructions or other trap instructions. Used by debugger.
6)
SIGABRT is generated when the program itself finds an error and calls abort.
6)
SIGIOT is generated by the iot instruction on PDP-11, and is the same as SIGABRT on other machines.
7)
SIGBUS illegal address, including memory address alignment errors. eg : access to a four
- integer whose address is not a multiple of 4.
8)
SIGFPE is issued when a fatal arithmetic error occurs. Not only floating point errors, but also
overflow and division by 0, all others Arithmetic error.
9)
SIGKILL is used to immediately end the execution of the program. This signal cannot be blocked, handled or ignored.
10)
SIGUSR1 is reserved for the user to use
11)
SIGSEGV attempted to access memory not allocated to itself, or attempted to write without permission
12) SIGUSR2 is
reserved for users to use
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 terminates (terminate) signal , unlike SIGKILL, this signal can be blocked and
handled . It is usually used to ask the program to exit normally. The shell command kill generates this
signal by default.
17)
SIGCHLD When the child process ends, the parent process will receive this signal.
18)
SIGCONT allows a stopped process to continue execution. This signal cannot be blocked.
A to make the program continue from the stopped state Complete specific
work . For example, redisplay the prompt
19)
SIGSTOP Stops the execution of the process. Note the difference between it and terminate and interrupt:
the process has not ended, just suspended execution. This signal cannot be blocked, handle or ignore.
20)
SIGTSTP stops the process from running, but this signal can be handled and ignored.
This signal is emitted when the user types the SUSP character (usually Ctrl-Z)
21)
SIGTTIN When a background job wants to read data from the user terminal, this signal All processes in the job will receive the SIGTTIN
signal. By default these processes will stop executing.
22)
SIGTTOU is similar to SIGTTIN, but received when writing to the terminal (or changing the terminal mode).
23)
SIGURG has "urgent" data or Generated when out-of-band data arrives at socket.
24)
SIGXCPU exceeds CPU time resource limit. This limit can be read/
changed by getrlimit/setrlimit
25)
SIGXFSZ exceeds 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
time .
28)
SIGWINCH When the window size changes Issue.
29)
SIGIO file descriptor is ready to start 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.
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 a CORE file Segment illegal error
SIGFPE Create CORE file Floating point exception
SIGIOT Create CORE file Execute I/O trap
SIGKILL kill process kill process
SIGPIPE kill process write data to a pipe without reading process SIGALARM kill process SIGTERM kill process
when timer expires software kill signal SIGSTOP stop process stop signal from non-terminal SIGTSTP stop process stop signal from terminal SIGCONT ignore Signal continues execution of a stopped process SIGURG Ignore signal I/O emergency signal SIGIO Ignore signal I/O can be done on descriptor SIGCHLD Ignore signal Notify parent process when child process stops or exits SIGTTOU Stop process Background process writes terminal SIGTTIN Stop process background Process reading terminal SIGXGPU Terminate process CPU timeout SIGXFSZ Terminate process File length is too long SIGWINCH Ignore signal Window size changes SIGPROF Terminate process Statistical distribution graph timer expires SIGUSR1 Terminate process User-defined signal 1 SIGUSR2 Terminate process User-defined signal 2 SIGVTALRM Terminate When the process virtual timer expires 1) SIGHUP This signal is issued when the user terminal connection (normal or abnormal) ends, usually in the control of the terminal.



















When the control process ends, notify each job in the same session, and they are
no longer .
2) SIGINT
program termination (interrupt) signal, issued when the user types the INTR character (usually Ctrl-C)
3)
SIGQUIT Similar to SIGINT, but controlled by the QUIT character (usually Ctrl-).
The core file is generated when a process exits on receipt of SIGQUIT, in the sense that it is similar to a program error
signal .
4)
SIGILL executes an illegal instruction. Usually because of an error in the executable file itself, or an attempt to execute a
data segment. This signal may also be generated when the stack overflows.
5)
SIGTRAP is generated by breakpoint instructions or other trap instructions. Used by the debugger.
6)
SIGABRT The program finds the error itself and Generated when abort is called.
6)
SIGIOT is generated by the iot instruction on PDP-11, and it is the same as SIGABRT on other machines.
7)
SIGBUS Illegal address, including memory address alignment errors. eg: accessing a four
- Integer, but whose address is not a multiple of 4.
8)
SIGFPE is issued when a fatal arithmetic error occurs. Not only floating-point errors, but all other arithmetic errors such
as and division by 0.
9)
SIGKILL is used to immediately end the execution of the program. This signal cannot be blocked, handled or ignored.
10)
SIGUSR1 is left to the user.
11)
SIGSEGV An attempt was made to access memory not allocated to itself, or to write data to a memory address that does not have write permission.
12)
SIGUSR2 is reserved for users to use
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 terminates (terminate) signal, which is different from SIGKILL This signal can be blocked and
handled . It is usually used to ask the program to exit normally. The shell command kill generates this
signal by default.
17)
SIGCHLD When the child process ends, the parent process will receive this signal.
18)
SIGCONT makes a stop( The process stopped) continues execution. This signal cannot be blocked.
A to let the program do specific
work when it changes from the stopped state to continue execution. For example, redisplay the prompt
19)
SIGSTOP Stop the execution of the (stopped) process . Note the difference between it and terminate and interrupt:
the process has not ended, just suspended execution. This signal cannot be blocked, handled or ignored.
20)
SIGTSTP stops a process from running, but this signal can be handled and ignored.
This signal is emitted when the user types the SUSP character (usually Ctrl-Z)
21)
SIGTTIN When a background job wants to read data from the user terminal, all processes in the job SIGTTIN
signal is received. By default these processes will stop executing.
22)
SIGTTOU is similar to SIGTTIN, but received when writing to the terminal (or changing the terminal mode).
23)
SIGURG has "urgent" data or out-of-band Generated when data arrives at socket.
24)
SIGXCPU exceeds CPU time resource limit. This limit can be read/
changed by getrlimit/setrlimit
25)
SIGXFSZ exceeds file size resource limit.
26)
SIGVTALRM virtual clock signal. Similar to SIGALRM, but calculated is 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
time .
28)
SIGWINCH is issued when the window size changes.
29)
SIGIO file descriptor is ready, can Start an input/output operation.
30)
SIGPWR Power failure

There are two signals that can stop a 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 level audit


w ##View the current users who are using the system

w -f ##-f to see where to use

2. Last View user login success history


3. Lastb view the history of unsuccessful user login

8. System initialization procedure

1. The systemd system initialization program, the first program started by the system, has a pid of 1

2. systemctl command

systemctl list-units ##List the status of the current system service
systemctl list-unit-files ##List the boot status of the service
systemctl status sshd ##View the status of the specified service
systemctl stop sshd ##Close the specified service
systemctl start sshd ## Start the specified service
systemctl restart sshd ##Restart the service
systemctl enable sshd ##Set the specified service to start on
systemctl disable sshd ##Set the specified service to start and close
systemctl reload sshd ##Make the specified service reload the configuration
systemctl list-dependencies sshd # #View the dependencies of the specified service
systemctl mask sshd ##Freeze the specified service
systemctl unmask sshd ##Enable the service
systemctl set-default multi-user.target ##Turn on the graphics
systemctl set-default graphical.target ##Start the graphics
setterm ##Text interface setting color
vga=ask

(The sshd in the above command refers to the remote login service, which refers to all service names)

3. Service status

systemctl status service name

loaded ##The system service has been initialized and the configuration has been loaded

active(running) ##One or more programs are being executed in the system,
                # vsftpd is this mode

atcive(exited) ##Only executed once A service that ends normally,

atcive(waiting) ## is executing,
                # but wait for other events to continue processing

inactive ## service shutdown

enbaled ## service startup

disabled ## service startup does not automatically start

static ## service startup The startup item cannot be managed

failed ##System configuration error


Guess you like

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