Wednesday, June 13, 2007

Disable All Users From Logging Into the System

There are times when you may need to prevent users from logging into the system. Here is a way of doing that.

# cat > /etc/nologin
The system is currently unavailable to all users. Try back in two hours.
Ctrl+d

Here is the message you will get when you try to login as a user. As you can see, it echoes the contents of the /etc/nologin file.

# login
login: esofthub
Password:
The system is currently unavailable to all users. Try back in two hours.

4 comments:

Anonymous said...

and then how do you reenable logins?

esofthub said...

Delete or mv (rename) the nologin file with the super user account, root. The nologin file has no effect on it.

Stephane said...

I doubt that "cat" understands the ":wq" ... seems more like vi :-)

Maybe you meant something like cat > /etc/nologin <<EOF (heredoc stuff ?)

esofthub said...

stephane, I'm chuckling over here in Korea. I can't believe I did that. It was a late night post, and I didn't proof the post. I'll make the correction. Thanks for keeping me straight. Roy