Restrict/unrestrict user login

A way to restrict/unrestrict user login in linux system
Linux
Author

Zeel B Patel

Published

July 24, 2023

Restrict/unrestrict user login in linux system

  • To restrict user login:
sudo usermod -s /usr/sbin/nologin username
  • Check if the user has been restricted:
sudo su - username

It will show a message similar to the following:

This account is currently not available.
  • To unrestrict user login:
sudo usermod -s /bin/bash username