Last mod: 2024.11.26
Linux system tools for monitoring
Learn how to monitor and optimize your Linux system with powerful tools designed for resource management analysis. Whether you are tracking CPU usage, managing disk space, or ensuring smooth system operations, these essential utilities provide the insights you need to keep your system running efficiently. Perfect for beginners and advanced users alike.
CPU, RAM and processes usage
The primary tool for checking CPU and RAM load is the :
top
More advanced and thus requiring more resources is:
htop
Linux process listing
We can list the processes running on the system:
ps -ef
Where:
- e - select all processes
- f - full format listing
Displayed columns:
- UID - user ID that owns the process
- PID - process ID
- PPID - parent process ID
- C - CPU usage percentage
- STIME - process start time
- TTY - associated terminal
- TIME - CPU time consumed
- CMD - command used to start the process
To limit the processes displayed, we can use this grep command to filter the returned results to keywords:
ps -ef|grep postgres
With bash command kill we can stop the selected process:
sudo kill 16900
Where:
- sudo - if we are not owner of process then we have to call command as super user
- 16900 - example PID (process ID)
If process is not responding we can call kill with -9 option, this will kill the process immediately:
sudo kill -9 16900
HDD/SSD storge
Checking free space on partitions:
df -h
Where:
- h - human readable format listing
Network interfaces
Show interfaces with IP addresses:
ip addr show
We can also install the older net-tools package:
sudo apt install net-tools -y
And use the command (similar to ipconfig from MS Windows):
ifconfig
To display existing network connections, we can use the command:
sudo netstat -tupan
Where:
- t - displays TCP connections
- u - displays UDP connections
- p - shows the process ID (PID) and program name of the process that owns each socket. Requires superuser privileges, so you might need sudo to use this option fully.
- a - displays all sockets, including: listening sockets, non-listening sockets
- n - displays numerical addresses and port numbers instead of resolving hostnames or service names