w truncates usernames!

It turns out that w truncates usernames to eight characters.
I was intending to use it to get a list of graphically-logged in users by running w -sf | grep :0 | awk ‘{print $1}’
However, I have some users with usernames longer than eight characters. Making sure the first eight characters of all users are unique is not a real fix; it’s a crappy workaround.
So how do I do this?

Moreover, when I type w -n I get this:

Usage:
w [options]
Options:
-h, --no-header do not print header
-u, --no-current ignore current process username
-s, --short short format
-n, --no-truncat non truncated listing (large)
-f, --from show remote hostname field
-o, --old-style old style output
-i, --ip-addr display IP address instead of hostname (if possible)
–help display this help and exit
-V, --version output version information and exit

Same with w --no-truncat
It tells me to use the command but the command is not implemented. What in the hell???

On 2015-05-30 02:56, Prune wrote:
>
> It turns out that w truncates usernames to eight characters.
> I was intending to use it to get a list of graphically-logged in users
> by running w -sf | grep :0 | awk ‘{print $1}’
> However, I have some users with usernames longer than eight characters.
> Making sure the first eight characters of all users are unique is not a
> real fix; it’s a crappy workaround.
> So how do I do this?

Did you look at the manual? It says how to change the name length. It
also says where the info is read from.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

Why would I look at the manual when the command itself displays argument information?
If that information is blatantly wrong, as I’ve shown, you can’t blame the user for not referring to additional information — that’s a ludicrous proposition.

Well just maybe it may conatain additional information such as


ENVIRONMENT
       PROCPS_USERLEN
              Override the default width of the username column.  Defaults to 8.

       PROCPS_FROMLEN
              Override the default width of the from column.  Defaults to 16.



OMG I read the manual and learned something :open_mouth:

On Sat, 30 May 2015 00:56:02 +0000, Prune wrote:

> It turns out that w truncates usernames to eight characters.
> I was intending to use it to get a list of graphically-logged in users
> by running w -sf | grep :0 | awk ‘{print $1}’
> However, I have some users with usernames longer than eight characters.
> Making sure the first eight characters of all users are unique is not a
> real fix; it’s a crappy workaround.
> So how do I do this?

‘who’ instead will give you full names. ‘w -n’ is supposed to work, but
at least on 13.2, it doesn’t seem to here.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On Sat, 30 May 2015 02:16:01 +0000, Prune wrote:

> Why would I look at the manual when the command itself displays argument
> information?
> If that information is blatantly wrong, as I’ve shown, you can’t blame
> the user for not referring to additional information — that’s a
> ludicrous proposition.

Guys - there’s no need to be rude to each other. Let’s keep it friendly.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2015-05-30 04:16, Prune wrote:
>
> Why would I look at the manual when the command itself displays argument
> information?

Because it doesn’t show all the information, perhaps? :slight_smile:

Command help is typically just a quick help to remind you of what you
should already have seen in the manual. In the manual (and some times
two manual flavours) you find all the options and explanations.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

It does give me full names. However, the results from who and w are different beyond just the user attributes displayed – the users displayed are different. For example, who shows the login screen as user (unknown) on the display (:0 for the primary).

Before login:

lipschitz@osiris:~> w
14:53:07 up 19:55, 3 users, load average: 0.12, 0.07, 0.06
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
lipschit tty1 14:51 1:15 0.08s 0.08s -bash
lipschit pts/0 172.16.1.100 14:51 3.00s 0.10s 0.00s w
lipschitz@osiris:~> who
lipschitz tty1 2015-05-30 14:51
lipschitz pts/0 2015-05-30 14:51 (172.16.1.100)
(unknown) :0 2015-05-30 14:52 (:0)

After login, though, the users match:

15:01:09 up 20:03, 4 users, load average: 1.33, 0.29, 0.14
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
lipschit tty1 14:51 9:17 0.08s 0.08s -bash
lipschit pts/0 172.16.1.100 14:51 5.00s 0.11s 0.00s w
lipschit console :0 15:00 20:02m 0.00s 0.06s gdm-session-worker [pam/gdm-password]
lipschit :0 :0 15:00 ?xdm? 1:52 0.06s gdm-session-worker [pam/gdm-password]
lipschitz@osiris:~> who
lipschitz tty1 2015-05-30 14:51
lipschitz pts/0 2015-05-30 14:51 (172.16.1.100)
lipschitz console 2015-05-30 15:00 (:0)
lipschitz :0 2015-05-30 15:00 (:0)

Using who in the place of w in the command below does seem to cover what I’m trying to do, getting the full usernames
w -sf | awk ‘{if ($2 ~ “:0”) {print $1}}’
but I’m wondering whether there is a catch, other than having to watch out for user (unknown).

Hi
On the older procps (version 3.2.X) w -n works, I would guess when they forked (see the NEWS) it to procps-ng (3.3.X) it broke…

Sounds like a good reason to create a bug report…