Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
k spec specify sorting order. Sorting syntax is
[+|-]key[,[+|-]key[,...]] Choose a multi-letter key from the
STANDARD FORMAT SPECIFIERS section. The "+" is optional since
default direction is increasing numerical or lexicographic
order. Identical to --sort. Examples:
ps jaxkuid,-ppid,+pid
ps axk comm o comm,args
ps kstart_time -ef
As for working out what k is, I'll leave that as an exercise for the reader
"top -n 1" gives me output similar to what I want. But I'm suspicious about what it displays though. Because I'm running dozens of client processes which all consume CPU. ps command displays those processes, but the top command displays only a fraction of them.
You were advised to read the manpage(s) - had you done so, you would know:
- "ps" can be (even reverse) sorted on any column
- "top" can show threads individually, or accumulated.
Personally I find "ps" more useful for this kind of thing, as it can be setup to not require any post-processing.
Top doesn't have less processes. Top is designed to show the "top" consuming processes, according to how you sort the list. You can specify how many lines are shown, and what the list is sorted by. Your original question asked how to display the top processes consuming the cpu. That is what "top" was designed for. Showing the top processes consuming the most X.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.