[olug] Unix Tip: KEEP THAT USER OUT!

Christopher Cashell topher at zyp.org
Fri Dec 13 07:24:49 UTC 2002

At Thu, 12 Dec 02, Unidentified Flying Banana William Haisch, said:
> If I read this correctly, this keeps new logins off the system but what
> about users already logged on?  Just my dime....

Once you've created /etc/nologin, you can use a similar idea to the
original script presented, and terminate logins.  Use 'w' to get a
listing of people currently logged into the machine. Then use 'ps aux'
to get a listing of processes on the machine, and match up the starting
shells that are owned by the users on the system.  Then, as root, you
can 'kill -HUP <PID>'[1] the shell process for each user.

Because /etc/nologin prevents further logins, this only has to be done a
single time, instead of repeatedly as the original script suggests.

> William Haisch

  [1] I use -HUP instead of -9 (-KILL) because it allows for more
      graceful termination of the connection, as opposed to just
      immediately killing it.

| Christopher
| A: No.                                         |
| Q: Should I include quotations after my reply? |

More information about the OLUG mailing list