• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to reduce and/or add more columns or fields to top command in Linux (swap, memory, etc)


    I have already written an article explaining every field in the top command

    10 examples to help you understand top command usage in Linux

    In this article I will show you the steps using which you can control the list of columns you would like to see with the top command.

    By default we see the below columns when top is executed without any arguments
      PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    11584 root      20   0  116376   1012    844 R 99.9  0.0  18716:08 agetty
        1 root      20   0  133792   4156   2552 S  0.0  0.0   0:38.09 systemd
        2 root      20   0       0      0      0 S  0.0  0.0   0:00.04 kthreadd
        3 root      20   0       0      0      0 S  0.0  0.0   0:01.31 ksoftirqd/0
        5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
        7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0


    Adding a new column

    Here I would like to add one more field to monitor the "swap" memory usage per process
    To do this, press "f" which will show you below list of options

    Here if you see some of the options are bright white, these are the fields which are currently enabled by default, to which now we would like to add "SWAP" details





    so navigate to the row which contains SWAP as shown below


    and press "space" bar to select the highlighted option. Once you hit "space" bar, the highlighted option should turn to bright white color similar to other default options.

    To go back to the home screen of top, press "Esc"
    So now as you can see, a new column with "SWAP" has appeared at the last column


    Similarly you can add any other column from the list of fields


    Removing an existing column

    To reduce or remove a column also similar steps can be followed as explained above

    Press "f" to go to the list of fields and navigate to the option which you would like to remove from the default top home screen

    Press "space" bar to un-select the field, by doing this the colour of the field would turn back to normal white colour similar to all other disabled sections as shown below, here I disabled "RES" memory column, press "Esc" to go back


    So now the same has vanished from top home screen.



    Save the changes permanently

    To save the changes what you have made, so that the same is active when you execute top next time
    press "Shift+w"


    Once you press the same, you should see the above line as shown in the screenshot. The changes will be saved under your home folder using which top was executed

    Below is the content of my /root/.toprc
    top's Config File (Linux processes with windows)
    Id:i, Mode_altscr=0, Mode_irixps=1, Delay_time=3.0, Curwin=0
    Def     fieldscur=¥¨³´»=ÃÃ
    efghij                         Â·ÂºÂ¹Ã
    &')*+,-.winflags=193844, sortindx=18, maxtasks=0, graph_cpus=0, graph_mems=0
            summclr=1, msgsclr=1, headclr=3, taskclr=1
    Job     fieldscur=¥¦¹·º(³´Ã
    efghij                            »½@<§Ã
    )*+,-./0winflags=193844, sortindx=0, maxtasks=0, graph_cpus=0, graph_mems=0
            summclr=6, msgsclr=6, headclr=7, taskclr=6
    Mem     fieldscur=¥º»<½¾¿ÃÃMBNÃD34·Ã
    ghij*+,-./0125689FGHIJKLOPQRSTUVWXYZ[\]^_`abcdeff
            winflags=193844, sortindx=21, maxtasks=0, graph_cpus=0, graph_mems=0
            summclr=5, msgsclr=5, headclr=4, taskclr=5
    Usr     fieldscur=¥¦§¨ª°¹·ºÃ
    efghij                               Ã
    )+,-./12winflags=193844, sortindx=3, maxtasks=0, graph_cpus=0, graph_mems=0
            summclr=3, msgsclr=3, headclr=2, taskclr=3
    Fixed_widest=0, Summ_mscale=0, Task_mscale=0, Zero_suppress=0

    I hope the article was useful.

    Deepak Prasad

    is a techie and an author who is still trying to survive in this IT generation with very little knowledge he has on Linux/Unix, VMware, SAN Storage, Automation, networking etc

    You can follow him on Facebook or Google+

    Do you also have something to share here?

    Become an author and be a part of our GoLinuxHub Team, Click here for more information
    How to reduce and/or add more columns or fields to top command in Linux (swap, memory, etc) How to reduce and/or add more columns or fields to top command in Linux (swap, memory, etc) Reviewed by Deepak Prasad on Sunday, May 06, 2018 Rating: 5

    No comments:

    Powered by Blogger.