ItecSoftware Logo

How to find memory usage by process?

Written by Peter Gilg on - like this:
memory usage from command line

As Linux system administrators, you take pride in being able to setup and maintain systems from the command line. But learning is never ending, and new tasks require a bit of research to find the correct tool for the job. Knowing more command line tools as you grow more experienced is a character that becomes evident in any seasoned veteran admin. One of those commands is to find memory usage by process.

Finding the processes that use most memory seems like a simple task, right? Well yes, but only until you need it right away. Just recently I needed to find the memory usage for a process and full of confidence, opening a console and start typing ps -……. Damn, what was it again. Let’s Google it. Hmm, first page, second page, third page and …  nada.

Keep in mind, I did not want some fancy utility, just a simple command at the terminal, that’s it. To spare you the time digging thru the man pages, here it is. You basically have to construct your own list of parameters with the “-o” switch.

For example, let’s find out how much memory our apache web server uses:

ps -Ao comm -o %mem

ps -A lists all processes, -o omits all formatting and only shows the value that follows. In our case, one for the Command name and one for the memory utilization. You can add whatever info you like and shed light into the inner workings of your server/workstation.

Listed in Linux

Tags: command, cpu, memory, process, ps, usage

One response to “How to find memory usage by process?”

  1. Anonymous says:

    Been looking for this for ages. There are plenty of utilities out there, but I like simple command line.

Leave a Reply

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