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.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

7 comments… add one
  • Mahesh Dec 5, 2007 @ 13:05

    i want to find the process execution time in LINUX???

    • boopathi Nov 2, 2010 @ 5:05

      time(command) | grep user|cut -f 2

      • obsolesced Sep 6, 2016 @ 9:45

        My time command writes to stderr instead of stdout, so I had to use (time command) 2>&1 | grep user

  • Tim Jun 26, 2008 @ 14:45

    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.

  • Ashish Jaiswal Nov 30, 2011 @ 6:49

    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

  • Pradeep H N Jul 24, 2012 @ 11:52

    atop and htop will never work on fedora

  • Sorin DANULESCU Aug 6, 2012 @ 21:58

    what about this command:

    ps axu | awk '{print $2, $3, $4, $11}' | head -1 && ps axu | awk '{print $2, $3, $4, $11}' | sort -k3 -nr |head -5

    The result is here

    2222 3.2 3.8 /usr/lib/firefox/firefox
    1937 0.2 1.5 /home/sorin/.dropbox-dist/dropbox
    1073 3.8 1.0 /usr/bin/X
    2407 0.2 0.9 pidgin
    4105 1.5 0.8 /usr/lib/firefox/plugin-container

    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

    ps axu | awk '{print $2, $3, $4, $11}' | head -1 && ps axu | awk '{print $2, $3, $4, $11}' | sort -k2 -nr |head -5


    3448 16.9 0.2 rsync
    1073 3.7 1.0 /usr/bin/X
    2222 3.2 3.7 /usr/lib/firefox/firefox
    830 2.5 0.5 /sbin/mount.ntfs
    4105 1.4 0.6 /usr/lib/firefox/plugin-container

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.