• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Juniper Client

Its all about Networks

  • Juniper SRX
  • Juniper eBooks
  • Juniper Switches
    • Juniper Ex Switch
    • Juniper Networks Switches
    • Juniper Switch
  • Juniper Apps
  • News
  • Juniper eBooks
  • About Us
  • Show Search
Hide Search

Easy methods to kind ps output

vijesh · November 13, 2020 · Leave a Comment

The ps command is essential to understanding what’s working in your Linux system and the sources that every course of is utilizing. It is helpful to know the best way to show the data that ps gives in no matter manner helps you concentrate on the issue you are making an attempt to resolve. One facet of that is having the ability to kind the output of the ps aux command by any column to spotlight specific info, resembling how a lot reminiscence processes are utilizing or how lengthy they have been working.

The trick includes utilizing the ps command’s –sort choice and realizing the best way to specify the column that you just need to use for the kind. By default, ps types by course of IDs (PIDs), exhibiting the smallest first. PID 1 will seem on the high of the record, proper beneath the column headings. The remainder will comply with in numeric order.

Here is an instance of the usual ps aux output. It in all probability appears to be like acquainted.

$ ps aux | head -5
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.2 169820 14028 ?        Ss   Nov01   0:52 /lib/systemd/systemd --system --deserialize 22
root           2  0.0  0.0      0     0 ?        S    Nov01   0:00 [kthreadd]
root           3  0.0  0.0      0     0 ?        I<   Nov01   0:00 [rcu_gp]
root           4  0.0  0.0      0     0 ?        I<   Nov01   0:00 [rcu_par_gp]

Utilizing the –sort choice, you’ll get the identical output should you kind by PID. Discover that it’s essential to enter “pid” in decrease case. Nevertheless, you possibly can change “pid” to another column and kind by that one as an alternative.

$ ps aux --sort pid | head -5
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.2 169820 14028 ?        Ss   Nov01   0:52 /lib/systemd/systemd --system --deserialize 22
root           2  0.0  0.0      0     0 ?        S    Nov01   0:00 [kthreadd]
root           3  0.0  0.0      0     0 ?        I<   Nov01   0:00 [rcu_gp]
root           4  0.0  0.0      0     0 ?        I<   Nov01   0:00 [rcu_par_gp]

To see the most important values for the chosen column listed first, you would need to change the kind choice (e.g., -pid rather than pid). Discover how the show on this case will then begin with the best course of ID. Consider – as that means descending values (largest first) and simply the title (e.g., pid) or the title with a plus signal prepended (e.g., +pid) as that means ascending. The command proven under types by course of ID exhibiting the most important first.

$ ps aux --sort -pid | head -5
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
shs       316468  0.0  0.0   8092   588 pts/0    S+   14:15   0:00 head -5
shs       316467  0.0  0.0  12052  4080 pts/0    R+   14:15   0:00 ps aux --sort -pid
root      316463  0.0  0.0      0     0 ?        I    14:14   0:00 [kworker/u8:1-events_power_efficient]
root      316453  0.0  0.0      0     0 ?        I    14:09   0:00 [kworker/0:0-events]

To kind by another column, it’s essential to use its column title. On this instance “pmem” means the share of reminiscence utilization and utilizing “-pmem” means we’ll see the processes utilizing essentially the most reminiscence first. You can additionally use “%mem” and “-%mem”.

$ ps aux --sort -pmem | head -5
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
gdm         1842  0.0  2.5 3765092 156612 tty1   Sl+  Nov01   3:44 /usr/bin/gnoe-shell
root      171907  0.0  0.9 130096 60232 ?        S<s  Nov06   0:06 /lib/systemdsystemd-journald
root        1431  0.1  0.8 146272 53900 ?        Sl   Nov01  17:58 nessusd -q
gdm         2310  0.0  0.8 798716 50032 tty1     Sl+  Nov01   0:00 /usr/bin/Xwaland :1024 -rootless -noreset -accessx -core -auth /run/person/121/.mutter-Xwayladauth.BPIVS0 -listen 4 -listen 5 -displayfd 6 -listen 7

In case you solely need to see choose columns of the ps output, you possibly can specify them as on this instance the place solely instructions and their CPU usages are proven and the output is sorted by the most important CPU utilization.

$ ps -eo comm,pcpu --sort -pcpu | head -5
COMMAND         %CPU
snmp             0.5
nessusd          0.1
systemd          0.0
kthreadd         0.0

Here is an inventory of the column names and strings that you should use to kind by them:

Column    Ascending Descending
Heading   Type      Type       Alternate options
===============================================
USER      person      -user
PID       pid       -pid
%CPU      pcpu      -pcpu      %cpu and -%cpu
%MEM      pmem      -pmem      %pmem and -%pmem
VSZ       vsz       -vsz
RSS       rss       -rss
TTY       tty       -tty
STAT      stat      -stat
START     begin     -start
TIME      time      -time
COMMAND   comm      -comm

Utilizing the kind command

You can even pipe the output of the ps aux command to the kind command and choose the column to make use of for sorting through the use of the column quantity (1 by 11). There are a few downsides to this strategy: 1) that your column headings shall be sorted together with the remainder of the ps output, doubtless ending up someplace you did not count on to see them; and a couple of) that it’s essential to add an “n” to your kind command when the kind must be numerical. The ps command perceive this distinction; kind doesn’t and must be nudged.

A command like this one would kind on reminiscence utilization. The type command makes use of “-nk 4” to (-n) kind numerically on the (-k 4) 4th information column within the kind output.

$ ps aux | head -1; ps aux | kind -r -nk 4 | head -6
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
gdm         1842  0.0  2.5 3765092 156612 tty1   Sl+  Nov01   3:46 /usr/bin/gnome-shell
root      171907  0.0  0.9 130096 60380 ?        S<s  Nov06   0:06 /lib/systemd/systemd-journald
root        1431  0.1  0.8 146272 53900 ?        Sl   Nov01  18:04 nessusd -q
gdm         2310  0.0  0.8 798716 50032 tty1     Sl+  Nov01   0:00 /usr/bin/Xwayland :1024 -rootless -noreset -accessx -core -auth /run/person/121/.mutter-Xwaylandauth.BPIVS0 -listen 4 -listen 5 -displayfd 6 -listen 7
gdm         2947  0.0  0.7 662908 43288 tty1     Sl   Nov01   0:00 /usr/libexec/ibus-x11 --kill-daemon
root        1007  0.0  0.6 943636 40296 ?        Ssl  Nov01   0:45 /usr/lib/snapd/snapd

Utilizing aliases

Even when the ps command’s flexibility meets your wants, you possibly can at all times create aliases in order that you do not have rely columns and/or take into consideration whether or not column values are numeric. Listed below are some examples:

alias ByCPU='ps aux --sort -%cpu'
alias ByMem='ps aux --sort -%mem'
alias TopCPU='ps aux --sort -%cpu | head -11'
alias TopMem='ps aux --sort -%mem | head -11'

Be part of the Community World communities on Fb and LinkedIn to touch upon matters which might be high of thoughts.

Copyright © 2020 IDG Communications, Inc.

Filed Under: News

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Which distributors are driving community technique? The reply would possibly shock you

Juniper extends Mist AI observability, efficiency administration capabilities

Engineers rush to grasp new abilities for AI-driven information facilities

HPE Aruba boosts NAC safety, provides GreenLake ‘kill swap’

Juniper Past Labs tackles AI networking, quantum safety

Surge in menace actors scanning Juniper, Cisco, and Palo Alto Networks gadgets

Chinese language cyberespionage group deploys customized backdoors on Juniper routers

HPE cuts 2,500 employees, expects Juniper purchase to shut finish of ’25, faces tariff points

Juniper CEO: ‘I’m disillusioned and considerably puzzled’ by DOJ merger rejection

Juniper unveils EX4000 entry switches to simplify enterprise community operations

What’s NaaS? Suppliers, supply fashions, and advantages defined

Timeline of HPE’s $14 billion bid for Juniper

For Searching IFSC Codes in Banks Visit Here

For Biographies visit Crazum.com

Footer

About Juniper Client

Juniper Client is a blog dedicated in solving juniper related problems like juniper srx load balancing, juniper routers, juniper switches etc. Juniper Client is the premier provider of information, intelligence and insight for Juniper Network and IT Executives. Our main focus is to deliver news, opinion and networking tools for managing business solutions. We offer a unique and valuable information for businesses to meet their marketing objectives. Read More...

FIND IT HERE

Copyright © 2026 · Daily Dish Pro on Genesis Framework · WordPress · Log in