Linux Learning Notes (Linux) system Management

Source: Internet
Author: User
Tags arithmetic pkill dmesg

1. Process Management

A process is a program or command being executed, each of which is a running entity that has its own address space and consumes a certain amount of system resources.

The role of process management is to determine the health status of the server, view all processes in the system, and kill the process. It is generally possible to terminate a process with the correct command, only to force the kill process if the termination fails.

(1) View all processes in the system

① ps aux command indicates viewing all processes in the system , using BSD OS format

User: who generated the process;

PID: The ID number of the process;

%CPU: The process consumes a percentage of CPU resources, the higher the consumption, the more resources the process consumes;

%MEM: The process consumes the percentage of physical memory, the higher the consumption, the more resources the process consumes;

VSZ: The amount of virtual memory that the process occupies, in kilobytes;

RSS: The process consumes the actual physical memory size in kilobytes;

TTY: The terminal in which the process is running. Where Tty1-tty7 represents the local console terminal Tty1-tty6 is the local character interface terminal, Tty7 is a graphics terminal. PTS/0-255 represents a virtual terminal;

STAT: Process state. The common state has R-run,s-sleep, T-stop state, S-contained subprocess, +--in the background ;

Start: The start time of the process;

time: The process takes up the CPU's operating times , not the system time;

Command: Produces the name of this process

The ② ps–le command indicates that all processes in the system are viewed using the Linux standard command format.

(2) View System health status

The top command completes this function in the form of:

Top [Options]

Where-D seconds: Specifies that the top command is updated every few seconds, and the default is 3 seconds for commands that can be executed in the interactive mode of the top command;

? or h: Show help for interactive mode;

P: Sort by CPU usage, this is the default;

M: Sort by memory utilization;

N: Sort by PID;

Q: Exit Top

The first five lines of the top command are indicated as follows:

The first line of information is the task queue information

Content

Description

12:26:46

System Current Time

Up 1 day, 13:32

System run time, the machine has been running 1 days 13 hours 32 minutes

2 users

Currently logged on two users

Load average:0.00, 0.00, 0.00

System before 1 minutes total, 5 minutes, 15 minute average load. Generally considered less than 1 o'clock, the load is small. If greater than 1, the system has exceeded the load

Second Behavior process information

Content

Description

task:95 Total

Number of processes in the system

1 Running

Number of processes that are running

94 Sleeping

The process of sleep

0 stopped

Processes that are stopping

0 Zombie

Zombie process, if not 0, requires manual check of zombie process

Third Behavior CPU Information

Content

Description

Cpu (s): 0.1%us

Percentage of CPU consumed by user mode

0.1%sy

Percentage of CPU consumed by system mode

0.0%ni

Percentage of CPU consumed by user processes that have changed precedence

99.7%id

CPU percent of idle CPU

0.1%wa

Percentage of CPU waiting for I/O process to occupy

0.0%hi

Percentage of CPU consumed by the hard interrupt request service

0.0%si

Percentage of CPU consumed by soft interrupt request Service

0.0%st

Steal time percent is the percentage of time that the virtual CPU waits for the CPU when there is a virtual machine

IV Behavior physical Memory information

Content

Description

mem:625344k Total

Total amount of physical memory, in kilobytes

571504K used

Amount of physical memory already in use

53840k Free

Amount of free physical memory

65800k buffers

Amount of memory as buffered

Five-line end swap partition (swap) information

Content

Description

swap:524280k Total

Total size of swap partition

0k used

Size of swap partition already in use

524280k Free

Size of the idle swap partition

409280k Cached

The size of the interactive partition as a cache

(3) View process tree

The role of Pstree is to view the process tree in the following format:

Pstree [Options]

Where the-p option shows the PID,-U option for the process to show the owning user of the process .

2. Terminate the process (1) Kill command

The Kill–l command allows you to view the available process signals .

Signal Code

Signal Name

Description

1

SIGHUP

This signal allows the process to close immediately and then re-read the configuration file after restarting

2

SIGINT

program termination signal for terminating foreground process, equivalent to output CTRL + C

8

SIGFPE

Emitted in the event of a fatal arithmetic operation error, including not only floating-point arithmetic errors, but also overflow and divisor 0 all other arithmetic errors

9

SIGKILL

Used to immediately end the operation of the program, this signal can not be blocked, processed and ignored, generally used to force the termination process

14

Sigalrm

Clock timing signal, which calculates the actual time or clock time, the alarm function uses the signal

15

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 terminate the process normally, we will try to sigkill signal, that is, signal 9

18

Sigcont

This signal allows the paused process to resume execution and the signal cannot be blocked

19

SIGSTOP

This signal can be paused foreground process, equivalent to input CTRL + Z shortcut key, this signal cannot be blocked

Example: Restarting a process

Kill-1 22354

Force Kill Process

Kill-9 22368

(2) Killall command

Killall can kill a process according to the process name in the following format:

killall [options] [signal] Process name

Where the-Ioption means interactive, asking if you want to kill a process, and the-I option means ignoring the case of the process name

(3) Pkill command

Similar to Killall, the format is:

pkill [options] [signal] Process name

Where the-t terminal number option indicates that the user is kicked out according to the terminal number

Cases:

#使用w命令查询本机已经登录的用户

W

#强制杀死从pts/1 Virtual terminal logon process

Pkill-9–t PTS/1

3. Work Management

Put the process into the background, there are two ways:1 tar–zcf etc.tar.gz/etc &;2) Top, in the process of the top command execution, press CTRL + Z shortcut . The former is run in the background, the latter is a background pause, and jobs can view the process suspended in the background .

The jobs–l command can display the work of the PID, note:"+" represents the most recent work that is put into the background, and is the default recovery when work resumes. "-" with the second bottom of the package to put the work back into the background.

The command to restore the background paused work to the foreground is FG, which is in the format:

FG% Work number

The% of the parameter% in the work number can be omitted, but note the difference between the work number and the PID.

Back up the background to perform the work, the command for the BG% work number , note: Background recovery executes the command, is unable to interact with the foreground, otherwise it can not be restored to the background, such as top and VI commands.

4. System Resource View

(1) The vmstat command is used to monitor system resources in the following format:

Vmstat [Refresh delay Refresh Count]

Example: Monitoring 3 system resources, 1 seconds each interval

(2) DMESG kernel detection information when booting

Example: View CPU information or NIC information of the kernel at boot time

DMESG | grep CPU

DMESG | grep eth0

(3) The Free command is used to view memory usage status

Free [-b|-k|-m|-g], where-b,-k,-m,-g represents the display in bytes, KB,MB,GB, and the default is KB.

The difference between buffering and caching: In short, caching (cache) is used to accelerate the "read" of data from the hard disk, while Buffering (bugger) is used to speed up the data "write" to the hard disk

(4) View CPU information

Cat/proc/cpuinfo, compared with the former , more detailed

(5) The uptime command displays the start time and average load of the system, which is the first line of top, and the W command can also see this data.

(6) View system and kernel-related information

uname [Options]

Where the-a option means viewing all relevant information about the system; the-r option means viewing the kernel version;-s option means view kernel name

Determine the number of bits of the current system:file [System external command], such as file/bin/ls, query the current release version of the Linux system: Lsb_release–a

(7) list The file information that the process opens or uses

lsof [Options]

Where the-C string option indicates that only files opened with a process beginning with a string are listed; the-u user name option indicates that only files that are open by a user's process are listed; the-P PID option indicates that a file that is opened by a PID process is listed.

5. System Timing Tasks

(1) Crond service Management and access control

Start command: Service Crond restart

Self-starting command: Ckoconfig Crond on

(2) User's crondtab settings

Format:crontab [Options]

Where the-e option edits the crontab Timer task, the-l option queries the crontab task, the-r option removes all crontab tasks for the current user.

Crontab–e will enter the crontab editing interface and will open vim to edit your work.

* * * * * * tasks performed

The asterisk meaning is as follows:

Project

Meaning

Range

1th "*"

The first few minutes of an hour

0-59

2nd "*"

The first hours of the day

0-23

3rd "*"

The first day of the one months

1-31

4th "*"

The first month of the year

1-12

5th "*"

The week of the week

0-7 (0 and 7 both represent Sunday)

Special symbols

Meaning

*

Represents any time. For example, the first "*" is meant to be executed every minute of 1 hours.

,

Represents a non-sequential time. For example, "0 8,12,16 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * command"

-

Represents a continuous time range. such as "0 5 * * 1-6 command", which represents the execution of commands from Monday to Saturday 5:0 A.M.

*/n

Represents how often it is executed. Like "*/10 * * * * * * * * * * * * * * * * * * * * * * * * * * * command"

45 22 * * * command

TD valign= "Top" width= "196" >

time

meaning

Execute command at 22:45

0 17 * * * 1 command

17:0 Weekly command

0 5 1,15 * * Command

5:0 A.M. per month 1th and 15th execute command

40 4 * 1-5 command

Every Monday to Friday wee hours 4:40 Execute command

*/10 4 * * * command

4 o'clock in the morning every day, executes the command every 10 minutes

0 0 1,15 * 1 commands

1th and 15th per month, 1 0 points 0 per week Will execute the command. Note: The day of the week and the date is best not to appear at the same time, because they define the days, very easy to let the administrator confused.

Note: in a timed task, the escape character "\" needs to be used before the special symbol. such as: Date +\%y\%m\%d

Linux Learning Notes (Linux) system Management

Related Article

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.