27.4. access.deny
To keep users from logging into the system when you are carrying out live updates, you can use the /etc/nologin method, available on most systems. When you create a file called nologin in /etc usually with the touch command, no users apart from root are allowed to log in.
If your system is one of the few that do not support the nologin method, all is not lost – you can create this function yourself. Here’s what to do.
Put the following code in your /etc/profile.
if [ -f /etc/nologin ]; then if [ $LOGNAME != "root" ]; then echo "Sorry $LOGNAME the system is unavailable at the moment" exit 1 fi fi
Now, when you want to stop all users logging in, apart from root that is, use the touch command to create a nologin file in /etc ...
Get Linux and Unix Shell Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.