Full username in top

top

On our systems user names can be up to 20 characters long. But the top commands only displays the first 8 characters.

How can I configure top to display the whole user name?

At the moment we use: top procps version 3.2.8 (linux)

But a different top implementation could be installed.

The oldest system we need to support is this:

Linux foohost 2.6.37.1-1.2-desktop #1 SMP PREEMPT 2011-02-21 10:34:10 +0100 x86_64 x86_64 x86_64 GNU/Linux

Best Answer

Looking at the sources of top, it seems that there's a hardcoded maximum of 8 chars:

1223    static FLD_t Fieldstab[] = {
1229          keys   head           fmts     width   scale  sort   desc                     lflg
1230         ------  -----------    -------  ------  -----  -----  ----------------------   -------- */
1235       { "EeDd", " USER    ",   " %-8.8s",  -1,    -1, SF(URE), "User Name",            L_EUSER  },

The fmts colum is a printf format string. %-8.8s means left padded string of minimum and maximum size of 8.

Related Question