How to Disable Shell Access for a Specific User

If you want to disable shell  access for a specific user quickly then you can use the below command  to achieve this, 

 

root@server[#] chsh -s /bin/false username

Example ::

 

root@server[#] chsh -s /bin/false rajbir
Changing shell for rajbir.
Shell changed.

OR

You can use the usemod command to change a user’s default shell

 

root@server[#]  usermod  -s /bin/false  username

Example ::

 

root@server[#]  usermod -s /bin/false  rajbir

 

That’s all easy isn’t it.