Operations 9 min read

Master Linux System Monitoring: Essential Commands and Tools for Ops

This guide explains how to efficiently monitor Linux systems using core commands and tools such as ls, ps, free, top, smem, and provides practical examples for checking CPU, memory, processes, disks, networks, and removing zombie processes.

Efficient Ops
Efficient Ops
Efficient Ops
Master Linux System Monitoring: Essential Commands and Tools for Ops

Command Line Learning Shortcut

Linux commands offer powerful capabilities, from simple disk and file operations to complex multimedia and streaming file creation, all relying on the command line.

Beginners often know many commands but struggle when a system fault occurs because theoretical knowledge is not well combined with practical system operations.

Five Key System Operation Areas

For operations, checking system status is fundamental. To monitor CPU, memory, processes, disks, and network, you need commands like ls, ps, free, top, uptime, ifconfig, su/sudo, dmesg, iostat, vmstat, sar, htop, iotop, smem, etc.

While many of these commands are simple, this article highlights a few powerful ones that act as essential tools for quickly understanding system status.

Typical Linux Command Line Tools

Linux uses virtual memory, making it non‑trivial to calculate the actual physical memory used by a process. smem is a command‑line tool that reports memory usage in various ways on Linux.

Memory Status Detection Tool

To install smem, enable the EPEL repository and run:

[root@localhost ~]# yum install epel-release
[root@localhost ~]# yum install smem python-matplotlib python-tk

To display memory usage for each process, run: smem -k -s uss The -k option shows memory units, -s sorts, and uss sorts by the USS column, producing a clear list of memory consumption per process. smem can also show memory usage as a percentage per process: smem -p It can display memory usage per user: smem -u Finally, you can query memory usage of a specific process, e.g.:

smem -P nginx
smem -k -P nginx

These features make smem an indispensable tool for operations.

CPU/Memory Intensive Processes

To list the top 10 processes consuming the most CPU, use a combination of ps, sort, and head:

[root@localhost ~]# ps aux | head -1; ps aux | sort -rn -k3 | head -10

The first command prints the header line. ps aux shows all processes ( a for all, u for user ID, x for processes without a controlling terminal). sort -rn -k3 sorts numerically in reverse order by the third column (%CPU). The pipeline (|) passes the output to the next command, and head -10 limits the result to ten lines.

Removing Zombie Processes

A zombie process appears after its child terminates; the process descriptor remains in memory. To detect zombie processes, run:

[root@localhost ~]# ps -e -o stat,ppid,pid,cmd | egrep '^[Zz]'

The -e flag lists all processes, -o defines the output format (status, parent PID, PID, command), and the regular expression ^[Zz] matches lines whose status starts with Z or z, which indicates zombie processes.

After obtaining the PID of a zombie, you can kill it with: [root@localhost ~]# kill -9 <span>pid</span> For many zombies, use a pipeline to batch‑kill them:

[root@localhost ~]# ps -e -o stat,ppid,pid,cmd | grep -e '^[Zz]' | awk '{print $2}' | xargs kill -9

This command extracts the parent PID column and passes it to kill -9 via xargs. While this removes zombies, the proper solution is to prevent them from being created.

Process ManagementSystem monitoringsmem
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.