The following command will lock an user account:
passwd --lock foo
or simply
passwd -l foo
Remember that, you should run the above command as root account.
If you want unlocking the account foo, just type the passwd command with -u or –unlock parameter, e.g:
passwd --unlock foo
or simply
passwd -u foo