Johnathan Johnathan -4 years ago 88
Linux Question

Unable to print usernames longer than 8 chars with "w" in linux

I am doing a linux script to extract which users are logged onto a machine, from where, and how long they have been idle.
So far I have been using the "w" command in linux.
However I now noticed that it truncates usernames and source

I have three users logged on

They are logged on from either: testserver, or superdupertestserver

The output of w is:

testuser pts/2 testserver 10:12 29.00s 0.15s 0.15s -bash
testuser pts/3 superdupertestse 10:12 21.00s 0.18s 0.18s -bash
lala-tes pts/4 superdupertestse 10:12 21.00s 0.18s 0.18s -bash

I am already using "long listing" of the output. Is there a way to fix this, or do get the information from the source w is using?

Answer Source

man w:

              Override  the default width of the username column.  Defaults to

              Override the default width of the from column.  Defaults to 16.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download