LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   What is the meaning of o/p of "who -u" commad (https://www.linuxquestions.org/questions/linux-server-73/what-is-the-meaning-of-o-p-of-who-u-commad-4175450512/)

techie_san778 02-17-2013 04:51 AM

What is the meaning of o/p of "who -u" commad
 
Hi friends,

I have few question on the o/p of the "who -u" command:
$who -u
San tty1 2013-02-17 15:35 old 2526 (:0)
San pts/0 2013-02-17 15:36 00:01 2714 (:0)
San pts/1 2013-02-17 15:36 . 3017 (:0.0)

Here, 3017 is the process id that is current process. Are 2714 and 2526 too process id's ? If so, then why don't they show up in ps command ?

What does the 4th Column (15:35, 15:36, 15:36)signify?

What does pts/0 and pts/1 mean ?

druuna 02-17-2013 05:10 AM

Those are indeed process id's.

Which ps command did you use? They do show up on my side:
Code:

# who -u
druuna  tty7        2013-02-17 08:45  old        3522 (:0)
druuna  pts/0        2013-02-17 12:02  .        27995 (:0.0)
druuna  pts/1        2013-02-17 12:05  .        28197 (stasis.wildfire.nl)

# ps -ef | grep 28197
root    28197  2898  0 12:05 ?        00:00:00 sshd: druuna [priv]
druuna  28205 28197  0 12:05 ?        00:00:00 sshd: druuna@pts/1

The fourth column shows the time the connection was set up/established.

In a nutshell: pts stands for pseudo terminal and one is needed for each connection (count start at 0)

techie_san778 02-17-2013 08:09 AM

See, in ur case, the process that is shown in the o/p of the ps command is 28197
which is the current process id (last process) in the who -u command o/p. But the others,
i.e. 27995 & 3522 are not shown.
Same is my case. Only the last process of the who -u is shown in the ps command o/p.
But not the other two. Why ?? that's my question .. got ??

druuna 02-17-2013 09:49 AM

Quote:

Originally Posted by techie_san778 (Post 4893612)
Only the last process of the who -u is shown in the ps command o/p.
But not the other two. Why ??

Because the example I give only looks for one specific PID.

ps -ef | egrep "28197|27995|3522" would have shown the processes for all three pids.

This would also work:
Code:

ps -fp 28197,27995,3522

techie_san778 02-18-2013 09:43 AM

I am using only ps command, with no options to grep any particular pid.
Then, all the pid's should show up.. right ?? Why, then only current pid is shown ? btw, what is the meaning of old in the 5th column ?

druuna 02-18-2013 10:27 AM

Quote:

Originally Posted by techie_san778 (Post 4894425)
I am using only ps command, with no options to grep any particular pid.
Then, all the pid's should show up.. right ??

Wrong!

A bare ps shows a limited amount of information. This from the ps man page:
Quote:

By default, ps selects all processes with the same effective user ID (euid=EUID) as the current user and associated with the same terminal as the invoker. It displays the process ID pid=PID), the terminal associated with the process (tname=TTY), the cumulated CPU time in [dd-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD). Output is unsorted by default.
The owner of the starting process (shown bu who -u) is root, so it isn't shown:
Code:

$ who -u
druuna  tty1        Feb 18 09:11 08:05        1958

$ ps -ef | grep 1958
root          1958    1  0 09:05 tty1    00:00:00 /bin/login --     
druuna    1986  1958  0 09:11 tty1    00:00:00 -bash
druuna    7260  7252  0 17:17 pts/0    00:00:00 grep 1958

$ ps                  # show only owned by druuna an attached to terminal
  PID TTY          TIME CMD
 7252 pts/0    00:00:00 bash
 7262 pts/0    00:00:00 ps

Quote:

btw, what is the meaning of old in the 5th column ?
I truly don't know.

shivaa 02-18-2013 10:50 AM

In addition to druuna's answers above, once go through manual of ps cmd, see here or invoke:
Code:

~$ man ps
You should use either of below options as well:-
Code:

-A              Select all processes. Identical to -e.

-a              Select all processes except session leaders (see
              getsid(2)) and processes not associated with a
              terminal.

So you can try:
Code:

~$ ps -aef | grep pid
OR
~$ ps -Af | grep pid
OR
~$ pgrep pid



All times are GMT -5. The time now is 09:52 PM.