


Here are some commands that reveal memory usage by user. $ alias mem-by-proc="ps aux | head -1 ps aux | sort -rnk 4" Don't forget to add it to your ~/.bashrc file if you want to make it permanent. If you like this command, you can set it up as an alias with a command like the one below. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

$ ps aux | head -1 ps aux | sort -rnk 4 | head -5 If we first display the heading for the ps output, this is a little easier to see. In the example above (truncated for this post), sort is being used with the -r (reverse), the -n (numeric) and the -k (key) options which are telling the command to sort the output in reverse numeric order based on the fourth column (memory usage) in the output from ps. Nemo 342 9.9 5.9 2854664 363528 ? Sl 08:59 4:44 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab Nemo 32542 8.9 7.6 2875428 462720 ? Sl 08:55 4:36 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab Nemo 400 3.4 9.2 3309580 563336 ? Sl 08:59 1:36 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab Here’s an example that provides a very useful display: $ ps aux | sort -rnk 4 | head -5 To get the most useful display for viewing the top memory users, however, you can pass the ps output from this command to the sort command. The ps command includes a column that displays memory usage for each process. The list will be limited by your window size, but the most significant processes with respect to memory usage will show up at the top of the process list. Tasks: 251 total, 3 running, 247 sleeping, 1 stopped, 0 zombie
