In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Linux how to check memory usage, the article is very detailed, has a certain reference value, interested friends must read it!
Checking memory is a very important skill for system administrators, and Linux provides many ways to monitor the usage of valuable memory resources.
Top I want to start with the most commonly used tools. The top command provides a real-time dynamic view of the running system, which checks the memory usage of each process. This is important because you can easily see that multiple examples of the same command consume different amounts of memory. Although you can't see this on a server without a monitor, you've noticed that turning on Chrome slows down your system. Run the top command to see that Chrome has multiple processes running (one for each tab-figure 1).
Figure multiple Chrome processes appear in the 1:top command.
Chrome is not the only application that displays multiple processes. Do you see the Firefox in figure 1? That is the main process of Firefox, and the Web Content process is its open tab. At the top of the output, you will see the system statistics. On my machine (System76 Leopard Extreme), I always have 16GB available RAM, of which only RAM that exceeds 10GB is in use. You can then collate the list to see the percentage of memory used by each process.
One of the best things about top is the process ID number (PID) of a service that may be out of control. With these PID, you can troubleshoot (or kill) problematic tasks.
If you want top to display more friendly memory information, use the command top-o% MEM, which causes top to sort all processes by the memory they use (figure 2).
Figure 2: sorting processes by memory usage in the top command
The top command also provides you with real-time updates about how much swap space is used.
Free sometimes, however, the top command may not meet your needs. You may only need to check the available and used memory of the system. In this regard, Linux also has the free command. The free command shows:
Total amount of physical memory available and used
The total amount of swapped memory in the system
Buffers and caches used by the kernel
In the terminal window, enter the free command. Its output is not real-time; instead, you will get an instant snapshot of the current free and used memory (figure 3).
Figure 3: the output of the free command is straightforward.
Of course, you can make free a little more friendly by adding the-m option, like this: free-m. This shows the memory usage in MB (figure 4).
The figure 4:free command is output in a form that is easier to read.
Of course, if your system is very new, you will want to use the-g option (in GB), such as free-g.
If you need to know the amount of memory, you can add the-t option, such as: free-mt. This will simply calculate the total memory in each column (figure 5).
Figure 5: provides you with free memory columns.
Another very convenient tool for vmstat is vmstat. This special command is a tip for reporting virtual memory statistics. The vmstat command reports about:
Process
Memory
Pagination
Blocking IO
Interrupt
Magnetic disk
CPU
The best way to use vmstat is to use the-s option, such as vmstat-s. This reports statistics in a single column (which is easier to read than the default report). The vmstat command will provide more information than you need (figure 6), but more is always better (in this case).
Figure 6: use the vmstat command to check memory usage.
Dmidecode what if you want to find more information about the installed system memory? To do this, you can use the dmidecode command. This special tool is the DMI table decoder, which dumps the system's DMI table contents into a human-readable format. If you don't know what the DMI table is, it can be used to describe the composition of the system (and the evolution of the system).
To run the dmidecode command, you need sudo permission. So enter the command sudo dmidecode-t 17. The output of this command (figure 7) can be long because it displays information for all memory types of devices. So, if you can't scroll up and down, you may need to send the output of the command to a file, such as: sudo dmidecode-t 17 > dmi_infoI, or pass it to a less command, such as sudo dmidecode | less.
Figure output of the 7:dmidecode command.
/ proc/meminfo you might ask yourself, "where do these commands get this information?" In some cases, they are obtained from the / proc/meminfo file. Did you guess? You can use the command less / proc/meminfo to read the file directly. By using the less command, you can scroll up and down the long output to find exactly what you need (figure 8).
Figure 8:less / proc/meminfo command output.
You should know about / proc/meminfo: this is not a real file. Instead, / proc/meminfo is a virtual file that contains real-time dynamic information about the system. In particular, you need to check the following values:
All memory (MemTotal)
Free memory (MemFree)
Available memory (MemAvailable)
Buffer (Buffers)
File cache (Cached)
Swap cache (SwapCached)
All switching areas (SwapTotal)
Idle Exchange area (SwapFree)
If you want to use / proc/meminfo, you can connect to the egrep command and use it: egrep-- color'Mem | Cache | Swap'/proc/meminfo. This will result in an easy-to-read list in which entries containing Mem, Cache, Swap, and so on will be colored (figure 9).
These are all the contents of the article "how to check memory usage by Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.