So while managing processes, you can also
manage user sessions and user-specific processes.
You can use common utilities like ps-u username.
That will show processes owned by a specific user.
And you can use pkill-u username.
Very convenient.
That will remove processes that are owned by a specific user.
So if you would see that a specific user is doing
something very bad, pkill-u username
will remove these bad things.
That sounds like fun.
Let me show you.
For this demo, I'm going to open another terminal
because it would be convenient if we have some processes
that we can manage.
So let's get back to a shell as usual, Linda.
And let's start a couple of sleep processes.
Infinity will sleep forever.
And let's also start something that sleeps for an hour.
And that is OK.
And next, I'm using ps-u Linda.
There we can see all the different processes
that are used by user Linda.
It's more than just the sleep processes
because she also owns the bash shell that
has been started for her.
And pkill-u Linda is doing what?
Well, let's verify.
ps-u Linda has terminated all the processes
that poor user Linda had started.
So that's one thing that you can do.
Another thing is login CTL.
Let's talk about login CTL a bit.
Login CTL is a part of systemd.
And it manages users and sessions.
One user can have multiple sessions open simultaneously.
And you use login CTL list users and login CTL list sessions
to show the users as well as the sessions.
Now, your login CTL user status on the UID
shows a tree of processes that are currently
opened by this user.
Use login CTL terminate session and login CTL terminate
user if you want to stop current sessions or users.
So let's check this as well.
Here we have login CTL list users
where we have the different users that are available.
And how about list sessions?
Well, we have multiple sessions for user Linda.
There's only one of them.
And the interesting thing is that you
can manage it from here.
Login CTL terminate user on user Linda.
And then I'm doing my list sessions again.
And user Linda is gone.
This is a convenient command if at any time
you see that a specific user is doing stuff
that you don't approve.
Login CTL terminate user.
And the user will be gone.