← 返回命令列表

Linux command

nologin 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

chsh -s nologin [user]

Customize message

echo "[declined_login_message]" > /etc/nologin.txt

说明

nologin displays a message that an account is not available and exits non-zero. It is designed as a replacement shell for accounts that should not be able to log in interactively. When set as a user's login shell, any attempt to log in as that user (via SSH, console, or su) is rejected. It is commonly used for system accounts (daemon, nobody, www-data) or to temporarily disable user accounts without deleting them. If /etc/nologin.txt exists, nologin displays its contents instead of the default message. On Linux (util-linux) the attempt is also written to syslog. Note: per-account nologin (this tool) is distinct from the pam_nologin PAM module, which disables all non-root logins system-wide via /etc/nologin or /var/run/nologin.

参数

-c, --command _command_
Ignored (accepted only for shell compatibility).
-h, --help
Display help and exit.
-V, --version
Display version information and exit.

FAQ

What is the nologin command used for?

nologin displays a message that an account is not available and exits non-zero. It is designed as a replacement shell for accounts that should not be able to log in interactively. When set as a user's login shell, any attempt to log in as that user (via SSH, console, or su) is rejected. It is commonly used for system accounts (daemon, nobody, www-data) or to temporarily disable user accounts without deleting them. If /etc/nologin.txt exists, nologin displays its contents instead of the default message. On Linux (util-linux) the attempt is also written to syslog. Note: per-account nologin (this tool) is distinct from the pam_nologin PAM module, which disables all non-root logins system-wide via /etc/nologin or /var/run/nologin.

How do I run a basic nologin example?

Run `chsh -s nologin [user]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -c, --command _command_ do in nologin?

Ignored (accepted only for shell compatibility).