(1) Process management
1. Determine the server health status
2. View the process
A. Viewing all processes in the system: PS
Example: PS aux (using BSD OS command format)
A show all foreground processes
X Show all background processes
U shows which user generated
Ps-le (using the Linux Standard command format)
-L display more detailed information
-E Show All processes
Result description
VSZ: Occupies virtual memory size kb
RSS: Occupies actual physical memory size KB
TTY: Process login terminal (? Indicates direct kernel generation, 1-7 for local console terminal, pts/0-255 virtual terminal)
STAT: status. R run, s sleep, t stop, s contains child processes, + in background
Start: Startup time
Time: CPU-intensive
Command: Commands to generate this process
B. View System health: Top
-D updates every few seconds, default 3 seconds
To use during the interaction:
?/h: Show Help for interactive mode
P: Sort by CPU usage
M: Sort by Memory utilization
N: Sort by PID
Q: Exit Top
Result description
Top-
18:31:55 System Current Time
Up 1 day,18:28, total operating time of the system
1 user, currently logged into 1 users
Load average:0.00, 0.00, 0.00 System in the first 5, 10, 15 minutes of the average load, greater than 1 is overloaded
Tasks: Number of processes
Total,
1 Running, running
Sleeping, sleep
0 stopped, stopping
0 Zombie Zombies
Cpu (s): Percentage of cups occupied
0.0%us, User mode
0.3%sy, System mode
0.0%ni, a user process that has changed precedence
99.3%id, idle (less than 20% requires hardware upgrade)
0.0%wa, waiting for input and output
0.0%hi, hard interrupt request service
0.3%si, soft interrupt Request Service
0.0%st virtual time, when there is a virtual machine, the virtual CPU waits for the actual CPU time
Mem: Physical Memory size KB
1004760k Total, Gross
867512k used, used
137248k Free, Idle
62176k buffers as Buffer
Swap: Swap partition size KB
2047996k Total, Gross
5492k used, used
2042504k Free, Idle
144888k Cached as Buffer
C. View all processes: Pstree
-P View Details
-U Show Process user
3. Kill the Process
A. Viewing the available process signals: kill-l
Example: kill-1 22222 restart PID
Kill-9 22222 forced termination
Kill 22222 Terminates normally
Signal Code Signal Name Description
1 SIGHUP This signal allows the process to shut down immediately and then re-read the configuration file after restarting
2 SIGHUP program termination signal for terminating the foreground process. Equivalent to CTRL + C
8 SIGFPE in the event of a fatal arithmetic operation error, including not only floating-point arithmetic errors, but also overflow and divisor of 0 other arithmetic errors
9 SIGKILL is used to immediately end the operation of the program, this signal can not be blocked, processed and ignored. Generally stronger than terminating the process
The SIGALRM clock timing signal calculates the actual time or clock. The alarm function uses this signal
SIGTERM the signal of the normal end process, the default signal of the KILL command. Sometimes if the process has been a problem, this signal is unable to properly terminate the process, we will try to sigkill signal, that is, signal 9
Sigcont let the suspended process resume execution, this signal can not be blocked
SIGSTOP This signal can pause the foreground process, equivalent to CTRL + Z. This signal cannot be blocked.
B. Kill all Processes: killall [options] [signal] Process name
-I interactive, asking if you want to kill a process
-I ignores process name capitalization
Example: Killall-9 mysqld
C. Terminating a process by process name: Pkill [Options] [signal] Process name
-T terminal number: Kick the user according to the terminal number
Cases:
View Current User: W
Kick-off User: pkill-9-t Tty1
(2) Work management
1. Put the process into the background
A. Background Run &: TAR-ZCF AA.TAR.GZ/AA &
B. Suspend ctrl+z:top in the background, press CTRL + Z during top execution
2. View jobs: Jobs-l
-L Display PID
Note: + represents the most recent one put into the background, and is also the default recovery work when working resumes. -Represents the penultimate second. [n] represents the work number
3. Restore background paused work to foreground: FG% Work number
Note:% can be omitted
4. Restore background paused work to the background: BG% work number
(3) System Resource View
1. Monitoring system resources: Vmstat [Refresh delay Refresh Count]
Example: Vmstat 1 3
2. Display kernel monitoring information at boot time (view hardware information): DMESG
Example: DMESG | grep CPU
3. View Memory Usage Status: Free [-b|k|m|g]
-B in bytes
-K in kilobytes (default)
-M in megabytes
-G in GB
4. View CPU Information: Cat/proc/cpuinfo
5. View System version: Cat/etc/redhat-release
6. Display system start time and average load: uptime
7. View system-to-kernel information: uname [Options]
-A view all relevant information about the system
-R View Kernel version
-S View kernel name
8. Determine the current number of system bits: File/bin/ls
9. Judging the current system release: Lsb_release-a
10. List the file information that the process opened or used: lsof [options]
-C String: Lists only the beginning of the string
-u user name: Lists only the specified user's
-P PID: Lists only the specified PID
(4) System timing tasks
1. Service Management and access control: Crond
Open: Service Crond start
Self-starting: Chkconfig Crond on
2. User's crontab settings: crontab [Options]
-e Edit Timed tasks
-L Query timed tasks
-R Delete all scheduled tasks for the current user
Format:
Time-sharing day and month task
Example: */10 0-23 1,15 * 1 date >> A.log: Every 23 minutes 1th and 15th per month and 0 to 10 every Monday
Linux notes (13)-System administration