Operating System - Linux
1825789 Members
2145 Online
109687 Solutions
New Discussion

Re: issues with usernames longer than 8 characters.

 
SOLVED
Go to solution
Alexander Chuzhoy
Honored Contributor

issues with usernames longer than 8 characters.

Hi all,
I noticed that whenever there's a username longer than 8 characters, programs like `who`,`w`,`ps` have problems displaying it. In particular:
`w` and `who` display just the first 8 characters, while `ps` displays the uid for these users instead of their username.

Does anyone know whether it's possible to overcome this limit?

Thanks.
5 REPLIES 5
Ivan Ferreira
Honored Contributor

Re: issues with usernames longer than 8 characters.

You can try setting this:

PS_FORMAT="user:15,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,command"

Then run "ps ax"
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Alexander Chuzhoy
Honored Contributor

Re: issues with usernames longer than 8 characters.

Thanks,
But this doesn't help me. Whenever there's a long username - `ps` simply replaces it with the respective UID.

Basically I have the workaround of executing `ps` with some options to get the UIDs of all users instead of their names and then to go over the list with some basic script to match the UID to the username, but I wonder if there's a solution for it.
Ivan Ferreira
Honored Contributor

Re: issues with usernames longer than 8 characters.

The PS_FORMAT should display correctly the usernames, it works for me. Probably, you need to increase the user: value.

With that format, long username should be displayed.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Alexander Chuzhoy
Honored Contributor

Re: issues with usernames longer than 8 characters.

If I use the exact commands as you gave me - I get only the following fields:
PID TTY STAT TIME COMMAND.

Never the less, the command:
`ps axo user:15,cmd`
shows even the long usernames on my systems (rhel 4).

Do you have any idea if there's something to do with the `w` command and the fact that it shows only 8 characters? I use the output from `w` in scripts...
Mike Stroyan
Honored Contributor
Solution

Re: issues with usernames longer than 8 characters.

The format in the 'w' command is hardcoded to "%-9.8s". You would need to edit the source and rebuild it to overcome the limit.
(Actually you could do a horrible hack to the binary. But what kind of sick mind would even think of something like that. ;-)

sed -e 's/9\.8/016/g' < /usr/bin/w > w
chmod +x w
./w