During maintenance, reject interactive logins for non-root users.
Show users the reason for the rejection.
Which file is commonly used?
/etc/nologin blocks non-root logins on implementations that support it and can display the file content as an explanation.
Detailed explanation
~/.nologinIncorrect. A file under one user's home does not represent a system-wide block.
Incorrect. A file under one user's home does not represent a system-wide block.
/etc/hostsIncorrect. /etc/hosts is a static name map.
Incorrect. /etc/hosts is a static name map.
/etc/nologinCorrect. /etc/nologin is the conventional maintenance lockout file.
Correct. /etc/nologin is the conventional maintenance lockout file.
/var/log/nologinIncorrect. /var/log is for logs, not the standard login-control file.
Incorrect. /var/log is for logs, not the standard login-control file.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'maintenance in progress' > /tmp/pathpass-nologin; cat /tmp/pathpass-nologin; rm -f /tmp/pathpass-nologinExpected result
maintenance in progressKey points
- /etc/nologin
- Blocks non-root logins
- Content can explain why
Notes
- Environment: GNU coreutils / /tmpの一時ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.