Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In top, I can see programs that are sleeping but are taking up memory and CPU. If a program is sleeping then how is this possible? Maybe it might have some memory reserved but then what about CPU?

Also, it says there are four users, but I can see only two users, myself and root. How can I find out who the other two users are?

share|improve this question
    
If I remember right, every user gets two terminals, one tty and one for X. – Bobby Aug 5 '10 at 13:04
up vote 4 down vote accepted

The user count is based on how many sessions are open. Each login terminal will increase the user count. You can get a list of everyone that is logged in and what they are doing with the w command.

melchiz ~ # w
 08:27:36 up 70 days, 17:13, 13 users,  load average: 0.18, 0.20, 0.22
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
lrvick   pts/0     Tue14   14:22m  0.02s  0.02s -bash
jspaldin pts/1     26May10  3:05   4:49   0.02s -/bin/bash
uw       pts/11    17Jul10 42:37m  0.16s  0.06s -/bin/bash
uw       pts/13    17Jul10 39:56m  0.12s  0.12s -/bin/bash
uw       pts/19    Wed16   16:06m  0.38s  0.36s vim Mathbot.py
lrvick   pts/20    Tue14   41:15m 53:04   0.00s sshd: lrvick [priv]
uw       pts/17    18Jul10 42:37m  5.21s  1.14s -/bin/bash
lrvick   pts/26    Wed19    6:30m  0.02s  0.02s -bash
jspaldin pts/27    10Jul10  4:35   0.16s  0.16s -/bin/bash
snail    pts/28    Wed16    8:21m  6.66s  6.64s irssi
root     pts/32    08:27    0.00s  0.02s  0.00s w
uw       pts/44    17Jul10 18days  1:21   0.02s -/bin/bash
snail    pts/30    Wed16   16:06m  0.06s  0.04s /usr/bin/python2.6

I suspect that the processes that you are seeing as sleeping and using CPU have actually just had a turn during the last poll cycle of top. top only updates the display every few seconds by default, and it's quite possible for a process to wake up, work, and go back to sleep during that time.

Unless it is using inordinate amounts of CPU, I would guess that is the case.

share|improve this answer
    
I see who and what, I wonder if there's a when and where? ;) – Wayne Werner Aug 5 '10 at 12:31
    
additionally you could list the users that have any process running with ps aux|awk '{ print $1 }'|grep -v USER|sort|uniq – matthias krull Aug 5 '10 at 12:34
    
(Sort of an addition:) The "sessions" are nothing more than records in the utmp file (/var/run/utmp on Linux). Some terminal emulators don't use utmp records (or at least have an option not to); some programs can add records not associated to terminals at all (vsftpd, samba). – grawity Aug 5 '10 at 20:32
    
@mugen: ps axo "user=" // ps -eo "user=" – grawity Aug 5 '10 at 20:35
    
@Wayne: "when" is 'LOGIN' and 'IDLE'. For network logins, "where" is displayed by w -f and who. (In the days of many terminals attached to a Big Server, the finger command would list users' offices, taken from the passwd file.) – grawity Aug 5 '10 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .