

That’s what I did on line 7, 8 and 9.Īs you can see, I can print PID, OWNER and COMMAND in my own format now. Now it’s time to process each line, store the colon delimited information in separate variables. Then loop through the output and print it on the screen.Īs you can see, I am getting the correct output.

Now, the first command I am going to run will give me the PID, OWNER and COMMAND of all the running processes separated by colon (:) symbol and store it in the RAWIN variable. Open the sysmon script with your favorite text editor, I am going to use Kate. Sysmon is the shell script that will display all the running processes PID, OWNER, MEMORY (in KB in descending order) and COMMAND. You can check memory usage (in percentage) of all the process running on your Linux operating system with the following command:

ps don’t really show you how much memory a process uses in KB or MB format, but it will show you how much memory is being used in percentage. There is one problem with this procedure. You can use the ps command to check memory usage of all the processes on Linux.

But it should work on any modern Linux distributions. I will be using Debian 9 Stretch for all the demonstration in this article. In this article, I will show you how to check memory usage of each of the processes running on your Linux machine. You can kill or stop these processes to free up RAM or memory, so that you can start your important programs. May be some of the processes are using a lot of memory that you don’t need right now. Imagine a case, where you want to run some program and it fails because you don’t have enough memory. Because, RAM or memory of your computer is limited. So, one of the basic task you do on your computer is to check how much memory or RAM (Random Access Memory) each of the process is using. If a process fails to allocate enough RAM or memory, then the process can’t be created and the program won’t be able to start. It is essential for the process to function correctly. Every process allocates some amount of RAM or memory for itself. The CPU has no problem handling all these programs because CPUs has multiple cores to handle multi-tasking.Įach of these programs runs as one or more processes. These days, a computer can run many programs at once.
