Option 1:
To disable user, use following commands
$usermod -s /sbin/nologin <UserName>
OR
$usermod -s /bin/false <UserName>
Both of the following command will change entry of UserName in /etc/passwd and set their shell to given shell. In our case it is either /sbin/nologin or /bin/false.
To enable user, use the same command again and give with /bin/bash or /bin/sh shell.
Option 2:
Other option is to Lock User with following command
$passwd -l <UserName>
The -l option disables an account by changing the password to a value which matches no possible encrypted value.
To Unlock user, Use following command
$passwd -u <UserName>
The -u option re-enables an account by changing the password back to its previous value
No comments:
Post a Comment