Q. How do I find out what process are eating up all my memory. Is it possible to find out how long that memory has been allocated to particular process? How do I kill that process to free up memory?
A. You need to use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
Simply type top command:
# top
top command will tell you the percentage of physical memory a particular process is using at any given time. As far as I know, there is no easy way that can tell how long that memory has been allocated.
You can also use ps command to get more information about process.
# ps aux | less
To kill process use kill command under Linux. Read man page of top and ls for more information.
🐧 7 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
i want to find the process execution time in LINUX???
time(command) | grep user|cut -f 2
My time command writes to stderr instead of stdout, so I had to use (time command) 2>&1 | grep user
I recommend using `htop’ instead of top to monitor processes. It’s much friendlier and easy to use, and allows you to do more. (It’s colorized too!)
It’s in the ubuntu repositories, I imagine you can install it easily for debian as well.
I prefer using atop.. which gives all the option network activity, disk activity and many more you can check in the man page of it
I dont know abt redhat and fedora but its there in ubuntu and debian repo
atop and htop will never work on fedora
what about this command:
The result is here
I see the 5 processes which consume most of the memory.
If I want to see the CPU, then I sort after second column => sort -k2
outputs: