[No audio]
Let's see monitor users.
We have created them, now we have to manage them,
because that's one of the basic job for any system
administrators or engineer or systems guy to monitor the
users, what they are doing in our system.
Some of the commands to monitor those users are who.
who tells you who is logged in into the system.
last, w, finger, and id.
These are the few commands.
There are many other commands as well, but these
are the few basic commands that are mostly used
in Linux environment where you can monitor users.
Let's look at our Linux machine by going into our
Linux console and run these commands to practice them.
[No audio]
Okay, we are logged in, let's clear our screen and see
who we are, good, we are ourselves, and we are in our directory.
And of course now you should know to type hostname,
and our hostname is the name of our system.
Let's clear this.
The first command is who. who is going to tell you
how many people are logged in, and their user ID,
their terminal ID, and the time they were logged in.
So I have logged in in my console, in my GUI
with column 0, and I have opened up a terminal right here.
It tells me the pts is the terminal, /0, and the time I opened it up.
If I wanted to open up another window,
so if you do right click and Open
Terminal, so you open up another terminal.
Now when you type who, it should show
you three terminals that says iafzal..
What if I log in as spiderman?
So let's go to our PuTTY terminal
and put in our IP address.
I believe it's 192.168.56.101,
sorry 56.101.
You could check that by again
running the command ifconfig.
There you go.
So we'll open that. Now
this time we log into, login as spiderman.
[Author typing]
Okay.
And now let's clear the screen and check.
[No audio]
Now you see we have 4. 1, 2, 3, 4, and
the fourth one is used by spiderman.
So this is the main function
or main purpose of the command
who. The reason we run this command who all the
time, or most of the time is when there is
a very high load in the system and you want
to see how many people are logged into the system.
Next command we're going to learn is last.
[Author typing]
Let's close the one in the back.
[Author typing]
last command tells you all the details of every users
that have been logged in since the day one.
So when you type last, hit enter, you see
everything comes up in the screen so fast.
I wanted to see one page at a
time, then how do I do that?
You do last, pipe it, and more it.
And this will tell you the last time
the user that logged in is spiderman.
Of course, this is the name, this is the user
that I logged in and this is the time I
logged in and it's telling you it is still logged
in and it tells you every user that's been logged
in and every user who's been logged in and rebooted
the system and whatever happened to the system.
So let's say if your system reboots or shuts down
or crashes unexpectedly, and you suspect someone was logged in
and you wanted to see what time they logged in,
which IP they used to log into, what date and
time they logged in, all the information is here.
If you wanted to see the first column of
your output of last, this is your last, right? last,
and you run that and you want to
see only the first column, all the usernames
only, then what command you would run.
This is a kind of pop quiz.
You do last, pipe it, awk, dollar one,
and you get the first one.
Now you just wanted to remove the duplicates,
then what do you do?
You do sort, that sorts out, and you
type uniq. There you go, and then you will see only
these other users have been logged in.
iafzal, reboot,
that's also a protocol that is
used to log in, spiderman,
and there's another user wtmp.
Another command that we learned is w. w works pretty
much the same as who, but it will give
you a little more information than who gives you.
The login time, the idle time, and what are
these processes being run by what user.
So it gives you a little more detail.
The next one is finger. When you run finger,
now finger command is the command that is added to
your system. So it does not come with your distribution,
you have to add it.
It's a program, it's a very powerful program.
It basically does the trace of your user, where
it's coming from, what kind of protocol it's using.
So you could need to install that.
So we will leave that out for now.
[No audio]
The next one is id.
When you hit id without the username, it will give
you the information about your own self. Your username, your
group id, and what part of other groups you are.
If you run id, and you do spiderman, then it
will give you the information about the other users.
So these are the few commands to monitor the users.
I hope you will remember them and
I hope you will practice them. Again,
the way to practice is to
run them with different options.
And how do you find the option, is by
running man, and do who, and you will find different
options and I would highly urge you to please
use different options just for practice.
[No audio]