As a Linux administrator it is sometimes necessary to stop users from login in to your box. This scenario is typically seen during system maintenance cycles, critical updates or scheduled/unscheduled software installs.

The easiest way to accomplish this is to simply create a nologin file in /etc/ .

To stop users from login in run the following command.

# touch /etc/nologin

To reverse the effect and allow users to log in run the following command.

# rm /etc/nologin

The above commands work fine on my CenOS5 and openSUSE 10.2 machines.