Just because you're paranoid doesn't mean they AREN'T out to get you... Source Unknown
From time to time there are going to be occasions where you will want to know exactly what people are doing on your system. Maybe you notice that a lot of RAM is being used, or a lot of CPU activity. You are going to want to see who is on the system, what they are running, and what kind of resources they are using.
The easiest way to see who is on the system is to do a who or w. The --> who is a simple tool that lists out who is logged --> on the system and what port or terminal they are logged on at.
user@server:~> who bjones pts/0 May 23 09:33 wally pts/3 May 20 11:35 aweeks pts/1 May 22 11:03 aweeks pts/2 May 23 15:04
In the previous section we can see that user aweeks is logged onto both pts/1 and pts/2, but what if we want to see what they are doing? We could to a ps -u aweeks and get the following output
user@server:~> ps -u aweeks 20876 pts/1 00:00:00 bash 20904 pts/2 00:00:00 bash 20951 pts/2 00:00:00 ssh 21012 pts/1 00:00:00 ps
This is a much more consolidated use of the ps than discussed previously.
Even easier than using the who and ps -u commands is to use the w. w will print out not only who is on the system, but also the commands they are running.
user@server:~> w aweeks :0 09:32 ?xdm? 30:09 0.02s -:0 aweeks pts/0 09:33 5:49m 0.00s 0.82s kdeinit: kded aweeks pts/2 09:35 8.00s 0.55s 0.36s vi sag-0.9.sgml aweeks pts/1 15:03 59.00s 0.03s 0.03s /bin/bash
From this we can see that I have a kde session running, I'm working in this document :-), and have another terminal open sitting idle at a bash prompt.