SoFunction
Updated on 2025-04-14

Common commands for Linux to view the current system's resource usage

In Linux systems, there are multiple commands to view the resource usage of the current system. Here are some commonly used commands and instructions:

1. Check memory usage: free

free -h
  • -hParameters are displayed in a human-readable format (such as MB, GB).

  • Output example:

             total        used        free      shared  buff/cache   available
Mem:           16Gi       4.2Gi       6.8Gi       238Mi       5.0Gi        11Gi
Swap:          2.0Gi       0.0Gi       2.0Gi

2. Check CPU usage: top or htop

top command:

top
  • topIt will display the system's real-time resource usage, including CPU, memory, processes, etc.
  • according toqquittop

htop command (need to be installed):

sudo apt install htop   # Ubuntu/Debian
sudo yum install htop   # CentOS/RHEL
htop
  • htopProvides a more friendly interactive interface, allowing you to more easily view CPU and memory usage.
  • according toF10quithtop

3. Check disk usage: df

df -h
  • dfDisplays the disk space usage of the file system.
  • -hParameters make the output easier to read (displayed in GB or MB).

Output example:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       100G   50G   45G  55% /

4. Check disk I/O usage: iostat

iostat -x 1
  • iostatUsed to view the system's disk I/O usage.
  • -xProvide more detailed information,1It means refreshing once every second.

5. Check the process occupancy: ps

ps aux --sort=-%cpu | head -n 10
  • Displays the top 10 processes with the highest CPU usage.
  • ps auxShow all processes,--sort=-%cpuSort by descending CPU usage.

6. Check network usage: netstat

netstat -tuln
  • Displays all current network connections and port occupancy.
  • -tulnParameters indicate the display of TCP connection (-t), UDP connection (-u), listen port (-l), and do not resolve domain names (-n)。

7. Check the overall usage of system resources: vmstat

vmstat 1
  • vmstatDisplays system memory, paging, process and other information.
  • 1It means refreshing once every second.

8. Check the system load: uptime or w

uptime
  • Displays the current time of the system, the system running time, the number of logged-in users, and the average load value of the load.

Output example:

 08:45:03 up 10 days,  3:21,  3 users,  load average: 0.12, 0.22, 0.25
  • load averageDisplays the system load of the past 1 minute, 5 minutes, and 15 minutes.

9. View kernel and system information: uname

uname -a
  • Displays the kernel version, operating system type, and other information of the system.

10. Check memory and cache usage: slabtop

slabtop
  • Displays the memory usage allocated by the kernel, which is usually used to view the kernel cache (slab cache).

Summarize:

  • usefreeandtopCheck memory and CPU usage.
  • usedfandiostatCheck the disk usage.
  • usepsCheck the process occupancy.
  • usenetstatCheck network connection.
  • usevmstatCheck the overall status of the system.

You can choose to use the above commands according to your specific needs to view the system's resource usage.

This is the article about the common commands for Linux to view the current system resource occupancy. For more related content on Linux to view resource occupancy, please search for my previous articles or continue browsing the following related articles. I hope everyone will support me in the future!