Linux Daily Management

Source: Internet
Author: User

1.W view current system load  load average: 0.03, 0.05, 0.00  The first value represents the average load value of the system within 1 minutes, The second number represents the average load of the system within 5 minutes, and the third number represents the average load value of the system within 15 minutes. This value represents the number of active processes for the CPU per unit of time, and the larger the value indicates the greater the pressure on the server. In general, this value does not matter as long as the number of CPUs on the server is not exceeded. 2. View the number of CPUs  cat /proc/cpuinfo | grep processor | grep -v grep   When viewing a few physical CPUs, filter the keyword "Physical id". 3.vmstat Monitoring System Status   can view CPU, memory, disk and other status.   (1) procs displays information about the process  r: the number of processes that represent the process running and waiting for CPU time slices. If the value is longer than the number of CPUs on the server, then the CPU is not enough.  b: Represents the number of processes waiting for a resource. such as waiting for I/O, memory, etc. If the value is greater than 1 for a long time, you need to look at it.   (2) memory-related information &NBSP;SWPD: Represents the amount of memory that is switched to the swap partition.  free: Indicates the amount of memory currently idle.  buff: Represents the buffer size (which will be written to disk).  cache: Represents the cache size (read from disk).   (3) Swap display memory swap  si: The amount of data written to memory by the swap area.  so: Represents the amount of data written to the swap area by memory.   (4) IO display disk usage  bi: Represents the amount of data read from a block device (read disk)  bo: Represents the amount of data written from a block device (write disk)   (5) The system displays the number of interrupts occurring during the acquisition interval   In: Indicates the number of interrupts per second that were observed at a certain time interval.  cs: Indicates the number of context switches produced per second.   (6) CPU displays CPU usage status  us: Displays the percentage of time that the user spends on the CPU.  sy: Displays the percentage of time the system spends on the CPU.  id: Represents the percentage of time that the CPU is idle.  wa: Indicates the time that I/O waits for the CPU consumedPercentage.  st: Indicates the percentage of the stolen CPU (typically 0, without concern). 4.TOP Displays the system resources occupied by the process  top commands are used to dynamically monitor the system resources consumed by the process, changing every 3s. In the top state, pressing the SHIFT+M key can be sorted by memory usage size. By the number 1, you can list the usage status of each CPU amount. &NBSP;TOP&NBSP;-BNL: Represents the usage of non-dynamic printing system resources. 5.sar Monitoring System Status  yum install -y sysstat sar command is powerful, he can monitor the status of all the resources of the system. such as the average load, network card traffic, disk status, memory usage, and so on.  sar -n dev: View network card traffic  sar -q: View historical load 6.free View memory usage  free -m free - G7.ps View System process   (1) PID: Indicates the system process number   (2) STAT: Indicates process status   process status There are several:  d: Represents a process that cannot be interrupted (usually IO).  r: Represents a running process.  s: Represents a process that has been interrupted. Typically, most of the system's processes are in this state.  t: Represents a process that has been stopped or paused.  w: After kernel 2.6.xx, there is not enough memory page allocation.  x: Represents a process that has died.  z: Represents a zombie process, which is a process that cannot be killed, kills, and consumes a bit of resources from the system.  <: Represents a high-priority process.  n: Represents a low-priority process.  l: Represents memory paging that has been locked in memory.  s: Represents the main process.  l: Represents a multithreaded process.  +: Represents a process that runs in the foreground. 8.netstat View network status &NBSP;NETSTAT&NBSP;-LNP: Print the current system boot which ports  netstat -an: Print network Connection Status 9. Grab Bag tool   (1) tcpdump (yum  install -u tcpdump) The &NBSP;TCPDUMP&NBSP;-NN&NBSP;-I&NBSP;ETH0:-NN option allows columns 3rd and 4th to be displayed as "ip+ port number" in the form of If you do not add the-NN option, the host name + service name is displayed. &nBSP; (2) Wireshark (Yum install -u wireshark) 10. Linux Network related   (1) Modify ip:/etc/sysconfig/network-scripts/ifcfg-eth0  (2) to set multiple ip:cp /etc/sysconfig/for the same NIC network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1  (3) Modify hostnanme:hostname  Hostname (This is stored in memory and will be restored after reboot),/etc/sysconfig/network  (4) Mii-tool eth0: View NIC Connection status   (5) Settings dns  It is very easy to set up DNS under Linux, as long as you write the DNS address to the configuration file/etc/resollv.conf.   In Linux there is a special file/etc/hosts can also resolve the domain name, but we need to manually add IP and domain name in the content. Its role is to temporarily parse a domain name. 11.Linux firewall   (1) selinux  the method of turning off SELinux executes the command "selinux=disabled", which defaults to enforcing. The configuration file is/etc/selinux/config, and after modifying the configuration file, restarting Linux will take effect. Temporarily turn off the SELinux command as "setenforce 0", you can use "Getenforce" to view the SELinux status. (2) The IPTABLES&NBSP;IPTABLES&NBSP;-NVL&NBSP;IPTABLES&NBSP;-F&NBSP;-NVL option represents the view rule, and the-f option represents the purge rule, but the purge is only temporary, Saved rules are also loaded after rebooting the system or restarting the Iptables service, so you need to use "/etc/init.d/iptables save" to save the rules.   (A) iptables 3 table  filter: This table is used for filtering packages, is a system preset table, built into 3 chains. The  input– acts on the package that enters the machine, the  output– acts on the packet sent by the machine, and the  forward– acts on the packets unrelated to the machine; NAT: This table is mainly used for network address translation, built-in 3 chains. The  prerouting– function is to change the destination address of the Baogang when it arrives at the firewall, and the  output– function is to change the destination address of the locally generated package; The  postrouting– effect is to change the source address of the package before it leaves the firewall Mangle: This table is mainly used to mark packets, and then to manipulate the corresponding packages according to the tags. (B) iptables basic syntax  iptables -t nat -nvl -t option followed by the table name,-NVL represents the rule to view the table, where-n means that the hostname is not resolved for IP,-l indicates that the list ,-V indicates that the information listed is more detailed. If you do not add the-t option, information about the filter table is printed. Iptables -f iptables -z -f means to remove all rules, Z means to set the packet and the flow counter zero. (C) iptables option  -a/-d: Indicates an Add/remove rule.  -i: means inserting a rule that actually works like-a.  -p: Indicates that a protocol can be made to make TCP, UDP, or ICMP.  –dport: Used with-p to indicate the specified destination port.  –sport: Used with-p to indicate the specified source port.  -s: Indicates the specified source IP (can make an IP segment).  -d: Represents the specified destination IP (can make an IP segment).  -j: followed by the action, where accept represents the Allow package, drop represents the drop packet, and reject represents a reject package.  -i: Indicates the specified network card.  -p: Represents a preset policy, followed by a chain, then followed by an action. Iptables -i input -s 1.1.1.1 -j drop iptables -d input -s  1.1.1.1 -j drop iptables -i input -s 2.2.2.2 -p tcp – Dport 80 -j drop Sometimes there are too many iptables on the server to delete a rule, but it is not easy to master the rules at the time of creation. In fact, there is a relatively simple way to first view the IPTAbles rules, such as iptables -nvl –line-numbers, then delete a rule, such as  iptables -D INPUT 1  Here-D followed by chain name, Rule Num. This num is the value of the 1th column when viewing the iptables rule. The ICMP package has a more common application, such as  iptables -I INPUT -p icmp –icmp-type 8 -j  drop  here the –icmp-type option is to be used with-p icmp, followed by the type number specified. This "8" refers to the ability to ping the other machine on the machine, while the other machine can not ping the machine. (3) Save and backup iptables rules  services iptables save; iptables-save > file;  iptables-restore < file;


This article is from "Ubuntu" blog, declined reprint!

Linux Daily Management

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.