Recently used Linux Command summary find route netstat ping watch killall iostat free top PS

Source: Internet
Author: User
Tags set time domain name server disk usage

The netstat command is used to display statistics related to IP, TCP, UDP, and ICMP protocols, and is typically used to verify the network connectivity of each port on the machine. Netstat is a program that accesses the network and related information in the kernel, and it provides reports on TCP connections, TCP and UDP snooping, and process memory management.

1. Command format:

Netstat [-accefghilmnnoprstuvvwx][-a< network type >][--IP]

2. Command function:

The netstat is used to display statistics related to IP, TCP, UDP, and ICMP protocols, and is typically used to verify the network connectivity of each port on the machine.

3. Command parameters:

-A or –all shows all sockets in the connection.

-a< network type > or –< network type > lists the relevant addresses in the network type connection.

-C or –continuous continues to list network status.

-C or –cache displays the cache information for the router configuration.

-E or –extend displays other relevant information about the network.

-F or –FIB displays the fib.

-G or –groups displays the multi-broadcast feature group members list.

-h or Help online Help.

-I or –interfaces displays the Web interface information form.

-L or –listening displays the socket of the server in the monitor.

-M or –masquerade displays the spoofed network connection.

-N or –numeric uses the IP address directly, not through the domain name server.

-N or –netlink or –symbolic displays the symbolic connection name of the network hardware peripherals.

-O or –timers displays the timer.

-P or –programs shows the program identification code and program name that are using the socket.

-R or –route displays routing Table.

-S or –statistice displays the statistics of network work information.

-T or –tcp shows the connection status of the TCP transport protocol.

-U or –UDP shows the connection status of the UDP transport protocol.

-V or –verbose shows the instruction execution process.

-V or –version displays version information.

-W or –raw shows the connection status of the raw transport protocol.

-X or –unix the effect of this parameter is the same as specifying the "-A Unix" parameter.

– IP or –inet the effect of this parameter is the same as specifying the "-A inet" parameter.

-at List all TCP ports

-PT show PID and process name in netstat output

-ANPT | grep ': 16064 ' Find the process running on the specified port

ping command

-D uses the So_debug function of the socket.

-F limit detection. Send a large and fast network packet to a machine to see its response.

-n outputs only numeric values.

-Q does not display information for any transmittal packets, only the final result is displayed.

-R ignores the normal routing Table and sends the packet directly to the remote host. This is usually a matter of looking at the network interface of this computer.

-R records the routing process.

-V shows the execution of the instruction in detail.

Number of <p>-c: Stop after sending a specified number of packages.

-I seconds: set interval a few seconds to send a network packet to a machine, the default value is one second to send once.

-I network interface: sends out packets using the specified network interface.

-L Pre-load: Sets the packets that are emitted before the requested information is sent.

-P Template style: Sets the template style that fills the packet.

-S Bytes: Specifies the number of bytes of data sent, the default value is 56, plus 8 bytes of ICMP header, which is a total of 64ICMP data bytes.

-T Survival value: Sets the size of the Live value TTL.

Watch Command

Watch is a very useful command, basically all Linux distributions with this gadget, like the name, watch can help you monitor the results of a command, save you to manually run over and over again. Under Linux, watch is the periodic execution of the next program, and full-screen display of the execution results. You can use him to monitor everything you want. The result of the command changes, such as tail a log file, ls monitoring a file size changes, see your imagination!

1. Command format:

watch[parameters [command]

2. Command function:

The output of the command can be output to a standard output device, which is used for periodic execution of commands/timed execution commands

3. Command parameters:

-N or--interval watch defaults to run the program every 2 seconds, you can use-N or-interval to specify the time interval.

-D or--differences use the-D or--differences option Watch to highlight the changed area. The-d=cumulative option highlights the changes that have been made (regardless of the recent change).

The-T or-no-title will turn off the watch command at the top of the interval, command, output of the current time.

killall Command

The Killall command in a Linux system is used to kill a process with the specified name (kill processes by name). We can use the KILL command to kill the process of the specified process PID, if we want to find the process we need to kill, we also need to use the PS and other commands to match grep to find the process, and killall the two processes into one, is a very useful command.

1. Command format:

killall[parameter [process name]

2. Command function:

Used to end all processes with the same name

3. Command parameters:

-Z kills only the process that owns Scontext

-e requires matching process name

-I ignore lowercase

-G kills Process group instead of process

-I interactive mode, ask the user before killing process

-l list all known signal names

-Q does not output a warning message

-S sends the specified signal

-V reports whether the signal was sent successfully

-W wait for process to die

--HELP Display Help information

--version Display version display

iostat Command

The Iostat in a Linux system is an abbreviation for I/O statistics (input/output statistics), and the Iostat tool monitors the system's disk operation activity. It is characterized by the reporting of disk activity statistics, as well as the reporting of CPU usage. Like Vmstat, Iostat also has a weakness, that is, it cannot analyze a process in depth, only the overall situation of the system. Iostat belongs to the Sysstat package. Can be installed directly with Yum install Sysstat.

1. Command format:

iostat[parameters [TIME] [number]

2. Command function:

Through the Iostat convenient to view the CPU, network card, TTY device, disk, CD-ROM and so on the activity of equipment, load information.

3. Command parameters:

-C Display of CPU usage

-D Display disk usage

-K displays in kilobytes

-m displays in units of M.

-N Display of disk array (LVM) information

-N Display of NFS usage

-p[disk] Displays disk and partition conditions

-t display terminal and CPU information

-X to display detailed information

-V Display version information

Free Command

The free command displays the idle, used physical memory and swap memory in the Linux system, and the buffer used by the kernel. In Linux system monitoring tools, the free command is one of the most frequently used commands.

1. Command format:

free [parameters]

2. Command function:

The free command displays system usage and idle memory conditions, including physical memory, interactive area memory (swap), and kernel buffer memory. Shared memory will be ignored

3. Command parameters:

-B Displays memory usage in bytes.

-K displays memory usage in kilobytes.

-m displays memory usage in megabytes.

-G displays memory usage in gigabytes.

-O does not display buffer throttling columns.

-s< interval seconds > Continuous observation of memory usage.

-T displays the memory sum column.

-V Displays version information.

Top Command

The top command is a common performance analysis tool under Linux that shows the resource usage of individual processes in the system in real time, similar to the Task Manager for Windows. Here is a detailed description of how it is used. Top is a dynamic display process where the current state can be refreshed continuously with the user key. If the command is executed in the foreground, it will monopolize the foreground until the user terminates the program. More accurately, the top command provides real-time status monitoring of the system's processor. It will display the most "sensitive" CPU in the system. Task List. This command can be used by CPU. Memory usage and execution time to sort tasks, and many of the features of the command can be set through interactive commands or in personal customization files.

1. Command format:

Top [parameters]

2. Command function:

Displays information about the processes currently being executed by the system, including process IDs, memory usage, CPU utilization, etc.

3. Command parameters:

-B Batch Processing

-C Displays the complete ruling command

-I ignores the failure process

-S Secret mode

-S cumulative mode

-i< time > Set time interval

-u< User name > Specify user name

-p< Process number > Specify process

-n< number of times > cycle display

Description

Statistical information Area:

The first five elements are the statistical information area of the current system situation as a whole. Let's look at the specific meaning of each line of information.

The first line, the task queue information, and the execution results of the uptime command, specify the following parameters:

14:06:23-Current system time

Up to 70 days, 16:44-the system has been running for 16 hours and 44 minutes (during which the system has not restarted the Yo!). )

2 users-currently has 2 users logged into the system

The three numbers behind the load average:1.15, 1.42, 1.44-load average are 1-minute, 5-minute, 15-minute loads respectively.

The load average data is the number of active processes that are checked every 5 seconds and then calculated by a particular algorithm. If this number is divided by the number of logical CPUs, the result above 5 indicates that the system is overloaded.

The second line, tasks-task (process), specific information is as follows:

The system now has 206 processes, of which there are 1 running, 205 in hibernation (sleep), 0 in the stoped state, and 0 in the zombie State (zombie).

The third line, CPU status information, the specific properties are described as follows:

5.9%us-the percentage of CPU occupied by the user space.

3.4% sy-The percentage of CPU consumed by the kernel space.

0.0% ni-The percentage of CPU that has changed the priority of the process

90.4% id-Idle CPU percentage

0.0% Wa-io waiting for CPU percentage

0.0% hi-Hard Interrupt (Hardware IRQ)% of CPU occupied

0.2% si-Soft Interrupt (software interrupts)% of CPU occupied

Note: In this case the CPU usage ratio differs from the Windows concept, and you need to understand the Linux system user space and kernel space knowledge!

Line four, the memory state, the specific information is as follows:

32949016k total-Total Physical memory (32GB)

14411180k used-Total Memory in use (14GB)

18537836k free-Total free memory (18GB)

169884k buffers-Cache Memory (169M)

Line five, swap swap partition information, specific information as follows:

32764556k total-Swap Area total (32GB)

Total swap area used by 0k used-(0K)

32764556k free-Total Idle swap area (32GB)

3612636k cached-Buffer Swap area total (3.6GB)

Note:

The total amount of memory in use in row four (used) refers to the amount of memory that is now controlled by the system kernel, and the total amount of free memory that the kernel has not included in its control range. The memory that is included in kernel management is not always in use, but also includes the memory that has been used in the past that can now be reused, and the kernel does not return these reusable memory to free, so there is less memory on Linux, but don't worry about it.

If you are accustomed to calculating the number of available memory, here is an approximate formula: The fourth line of Free + fourth row buffers + fifth row of cached, according to this formula this server's available memory: 18537836k +169884k +3612636k = 22GB or so.

For memory monitoring, in the top we have to monitor the fifth line swap partition used, if this value is constantly changing, indicating that the kernel is constantly in memory and swap data exchange, which is really not enough memory.

Line six, blank line.

Line seventh below: status monitoring of each process (task), the project column information is described as follows:

pid-Process ID

user-Process Owner

pr-Process Priority

The Ni-nice value. Negative values indicate high priority, positive values indicate low priority

The total amount of virtual memory used by the virt-process, in kilobytes. Virt=swap+res

The size, in kilobytes, of the physical memory used by the res-process and not swapped out. Res=code+data

shr-shared memory size, in kilobytes

S-process state. d= non-disruptive sleep status r= run s= sleep t= track/stop z= zombie Process

%cpu-percentage of CPU time that was last updated to current

Percentage of physical memory used by the%mem-process

Total CPU time used by the time+-process, Unit 1/100 sec

command-Process Name (command name/command line)

PS Command

The PS command in Linux is the abbreviation for process status. The PS command is used to list those processes that are currently running on the system. The PS command lists the current snapshots of those processes, which are those that are executing the PS command at the moment, and if you want to display process information dynamically, you can use the top command.

To monitor and control the process, you must first understand the current process, that is, you need to see the current process, and the PS command is the most basic and very powerful process view command. Use this command to determine which processes are running and running, whether the process is complete, if the process is zombie, which processes are consuming too many resources, and so on. In short, most of the information can be obtained by executing the command.

PS gives us a one-time view of the process, it provides a view of the results is not dynamic continuous, if you want to monitor the process, you should use the top tool.

The KILL command is used to kill the process.

There are 5 states of processes on Linux:

1. Running (running or waiting in the running queue)

2. Interrupt (dormant, blocked, waiting for a condition to form or receive a signal)

3. Non-interruptible (receive signal does not wake up and not run, process must wait until interrupt occurs)

4. Zombie (The process has been terminated, but the process descriptor exists until the parent process calls WAIT4 () after the system call is released)

5. Stop (process received Sigstop, SIGSTP, Sigtin, Sigtou signal after stop running run)

PS Tool identifies 5 status codes for the process:

D non-interruptible uninterruptible sleep (usually IO)

R run runnable (on run queue)

S Interrupt Sleeping

T stop traced or stopped

Z Zombie a defunct ("zombie") process

1. Command format:

ps[parameters]

2. Command function:

Used to display the status of the current process

3. Command parameters:

A Show All Processes

-a displays all programs under the same terminal

-A Show All processes

C Displays the real name of the process

-N Reverse Selection

-e equals "-A"

e Display Environment variables

F show the relationship between programs

-H Display tree structure

R shows the process of the current terminal

T displays all programs for the current terminal

U specify all processes for the user

-au Show more detailed information

-aux Show all itineraries that contain other users

-c< commands > lists the status of the specified command

--lines< lines > number of rows displayed per page

--width< characters > number of characters displayed per page

--HELP Display Help information

--version Display version display

Recently used Linux Command summary find route netstat ping watch killall iostat free top PS

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.