Operating System - Linux
1819870 Members
2352 Online
109607 Solutions
New Discussion юеВ

Kick/kill all users command?

 
Robert Nolan
New Member

Kick/kill all users command?


Is there a command I can use to kill all users on RH? Or do I have to run a script to gather all the PIDs, then kill each one wih kill -9?

I need to do a reboot and although that will obviously kill all processes, I was hoping to kill the users first to do some maintenance.

Any feeback greatly welcomed.
Regards,
Rob
7 REPLIES 7
Georg Tresselt
Honored Contributor

Re: Kick/kill all users command?

In my view, the answer is in your question. Everyone will be logged off when the system shuts down. What would be nice of you to do is sending a warning to the users by mail or wall before you take action.
http://www.tresselt.eu
Robert Nolan
New Member

Re: Kick/kill all users command?

Ye, thanks good call, however, I would rather kick all the users and then reboot later. So, is there a command I can use to kick all users?
xyko_1
Esteemed Contributor

Re: Kick/kill all users command?

Hi Robert,

try to change to init 1

#init 1

and in the system console make your maintenace before reboot.

This will solve your problem, I guess.

regards,
xyko
Chris Xu
Trusted Contributor

Re: Kick/kill all users command?

I would agree with xyko on changing your system to single user mode if you really want no users on your system. You can kill a user logon, but another user can always log on without knowing you are doing the maintenance. That said, there is command to kill a user, but all users at one shot. It's fuser. Check man page for necessary switches.

Chris
Balaji N
Honored Contributor

Re: Kick/kill all users command?

su - $user -c kill -9 -1

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Yong_7
Frequent Advisor

Re: Kick/kill all users command?

Hi,

I think you know you can shut the road down as root by stop the various services like telnet, ftp http etc.( # service telnetd stop ) that will keep you in multiuser mode if that's what you need to stay.

what i usually do is " #wall " people first, friendly ;-), then go to sigle user mode.

YJ.
Bharat Katkar
Honored Contributor

Re: Kick/kill all users command?

Hi Rob,
Here are some scripting guideline for killing all users and thier processes:

1. use "ps -ef" and grep on 6th field (use cut) and get ttynames.
2. ps -t and grep on process ID's and collect process ID's
3. kill -9

Hope that helps.
Regards,
You need to know a lot to actually know how little you know