How to check CPU and memory utilization in Linux Ubuntu? Here is the Linux command to check memory utilization in percentage or check memory usage Linux by process.
top Command
top is used to display Linux processes. It provides a dynamic real-time view of a running system. It displays system summary information as well as a list of processes or threads currently being managed by the Linux kernel.
The top command displays information about:
- uptime
- average load
- tasks running
- number of users logged in
- number of CPUs/CPU utilization
- memory/swap system processes
Note that the data is continuously updated and top command details the processes in real-time.
The top command provides a limited interactive interface for process manipulation as well as a much more extensive interface for personal configuration.
Two of the most important factors displayed by the top command are:
- %CPU — CPU Usage: The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported.
- %MEM — Memory Usage (RES): A task’s currently used share of available physical memory.
If you want to make top a bit more memory-friendly, issue the command top -o %MEM, which will cause top to sort all processes by memory used (see figure below).
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for processes are all user configurable and that configuration can be made persistent across restarts.
Another great command is htop. It is similar to the top command, but the htop command is more interactive. The htop command uses color for its output, displays full command lines for processes. Unlike top command, the htop command comes with the option to scroll both vertically and horizontally.