Wednesday, November 30, 2011

How to find out who is doing what in an UNIX system

OK, so you are here to learn how to find out who is doing what in your UNIX system.

Then first of all let me ask, who are you?
Now, you have a question in your mind, who am i?

type it down in your system and lets see what the system responds.

bash-3.00$ who am i
scott      pts/3        Nov 30 19:37    (10.203.54.223)

now you have your account name/user name, the communication line, date and time of login and your ip address as well.

Now you know who you are, right? Is that all that you need to know about you?

You know that UNIX is a multi user system. Hence the system you have logged in probably might have more users other than you. Rather than having a unique name, don't you think the UNIX system will have a unique id for each of the users in the system!! So let us check our what id Unix has assigned to you.

Type down what come to your mind. Nothing but id!!

bash-3.00$ id
uid=200(scott) gid=201(scott)


It give you both id and your group id as well. After all you don't need to bother much about UID and GID

Now you know who you are, and now its time for you to check who else is there in the system.

who

The only limitation here is, you can get details only on users who are currently logged in to the system.

bash-3.00$ who
scott      pts/2        Nov 30 11:31    (10.203.54.102)
taylor      pts/3        Nov 30 19:37    (10.203.54.223)
ram      pts/4        Nov 30 12:52    (10.203.54.4)
build      pts/5        Nov 24 19:15    (10.222.46.132)


Four users are logged into the same UNIX system. Their communication channel, the time they logged into the system and their system ip address is also listed down.


Now you know who all are there in the system. But do you know what they are doing? Watching some ...movies? You want to check it out?

Use the command "w", a combination of "who are they?" and "what they do?"

bash-3.00$ w
  8:02pm  up 215 day(s),  3:13,  8 users,  load average: 0.18, 0.20, 0.20
User     tty           login@      idle   JCPU   PCPU  what
scott    pts/2        11:31am    17                              bash
taylor    pts/3       7:37pm                                       bash


This command gives us info about the user name, ttyp, logged in time, how long since the user has done anything, combined CPU time of all jobs run by the user, CPU time taken by current job and last field tells you what the user is doing?


So, next time while you do something in your UNIX system, beware that other users can check it out, what you are doing!!

*All the commands explained here are tested against SunOS

No comments:

Post a Comment