sudo usermod -s /usr/sbin/nologin alice

Category: Administration

sudo usermod -s /usr/sbin/nologin alice

Disable shell login for a user

Setting the login shell to nologin means alice cannot open an interactive shell, though her other services and file access keep working. This is the clean way to lock down a service account without deleting it. Reverse it with usermod -s /bin/bash alice.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.