The following command will lock an user account:
passwd --lock foo
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
passwd -u foo