![]() | 2982 | /usr/bin/gnome-shell | 2.7 | 3 |įor ease of use and avoid typing this command over and over you can alias them into your. Which gives this beautiful output - | PID | CMD | %CPU | %MEM | Or, for something fancier, you can install a python package called tabulate, type this in your terminal pip install tabulate, now you can really show off, using some sed fu etc ps -e -o pid,cmd,%cpu,%mem -sort=-%cpu | head -n 5 | tabulate -1 -f github | cut -f 2-d "|" | sed '2s/-/ /' For example you can use watch to update the list every 2 seconds like this watch "ps -e -o pid,cmd,%cpu,%mem -sort=-%cpu | head -n 6" Now that we understand the basics we can show off a little. Then we pipe this into head -n 6 which gives us the this PID CMD %CPU %MEMĤ02083 /usr/lib64/firefox/firefox 4.2 6.7ĩ78875 /usr/lib64/firefox/firefox 3.6 4.0 Also -sort needs the parameter to sort by, which we provide by -%cpu notice the - this is so that it sorts descending and we get the highest CPU usage first. ![]() One important point to note here is that by default it sorts ascending. e shows every process on the system -o is to define the format we want the result in, as you can see we have specified the format as pid,cmd,%cpu,%mem, next -sort ofcourse, sorts. ps ofcourse shows a snapshot of current processes. So, for bare bones, type ps -e -o pid,cmd,%cpu,%mem -sort=-%cpu | head -n 6 ![]() Here is something I came up with as I found the original answer a bit too arcane.
0 Comments
Leave a Reply. |