7 command line tools for monitoring Linux systems

  
 

One of the best things about Linux is that you can go deep into the operating system
to explore how it works and look for opportunities to fine-tune performance or diagnose problems. Here are some basic command line tools that make it easier to explore and manipulate Linux. Most of these commands are built into your Linux system, but if they don't, use Google to search for the command name and your distribution name. You will find which packages need to be installed (note that some commands are Other commands are bundled and packaged into one package. The package you are looking for may be written with other names). If you know some of the other tools you use, welcome comments.

How do we get started


Note: The screenshots in this article are taken from a Debian Linux 8.1 (“Jessie”) running on OS X 10.10.3 ( “Yosemite”) A virtual machine in Oracle VirtualBox 4.3.28 under the operating system. To build your Debian virtual machine, check out my tutorial
——“how to install Debian” under the VirtualBox VM.

Top


As a relatively easy to use Linux monitoring tool, the top command takes us through almost every aspect of Linux. The following picture is its default interface, but press the “z” key to switch between different display colors. Other hotkeys and commands have other functions, such as displaying summary information and memory information (second line, second), sorting according to various conditions, terminating process tasks, etc. (you can find the complete list here) ).

htop


Compared to top, its replacement Htop is more refined. Wikipedia describes this as follows: “Users often deploy htop so that Unix top does not provide enough information about the system process. For example, when you are trying to find a small memory leak in your application, Htop can also be used as a The system listener is used. Compared to top, it provides a more convenient cursor control interface to send signals to the process. & rdquo; (For more details, poke here)

Vmstat


Vmstat is a simple tool for monitoring Linux system performance data, which makes it more suitable In the shell script. Make your regex tricks, use vmstat and cron jobs to do some exciting things. & nbsp; The latter report gives the mean after the last system restart, and another report gives the information from the interval from the previous report. Other processes and memory reports are the transient conditions & quo; (push here for more information).

ps


The ps command shows a list of processes that are running. In this case, we use the “-e” option to display each process, that is, all running processes (I scrolled the list to the front, otherwise the column names will not be visible). This command has a number of options that allow you to format the output as needed. Just use a little bit of regular expression techniques above and you'll get a powerful tool. Poke here for more information.

Pstree


Pstree“shows the running process as a tree. This process tree is rooted at a pid. If the pid is omitted, the tree is rooted at init. If you specify a username, all process trees will be displayed as the parent process for the process to which the user belongs. & rdquo; Using a tree diagram to help you classify the relationship between processes, this is indeed a very effective tool (poke here).

pmap


In the debugging process, it is important to understand how an application uses memory, and the role of pmap is to display when a process ID is given. Relevant information. The screenshot above shows some of the output generated by using the “-x” option. You can also use pmap's "-X” option to get more details, but only if you have a wider terminal. window.

iostat


A critical performance metric for Linux systems is processor and storage usage, which is what the iostat command reports. Like the ps command, iostat has a number of options that allow you to choose the output format you need, in addition to repeating samples over a certain period of time

Copyright © Windows knowledge All Rights Reserved