When someone leaves, or an account looks suspicious, locking the password is the quick first step. It is less complete than the name suggests.
sudo passwd -l olduser
sudo passwd -u olduser
The man page says -l disables the password by changing the stored value to one that matches no possible encrypted value. In practice it puts a ! in front of the hash. A locked user also cannot change their password. -u unlocks it again by restoring the earlier value.
The caveat is in the same man page: the user may still be able to log in with another authentication token, such as an SSH key. Locking the password does not stop key-based SSH logins. To disable the account properly, the man page recommends usermod --expiredate 1, which sets the expiry date to 1970-01-02:
sudo usermod --expiredate 1 olduser
sudo chage -l olduser
The chage -l line shows the account expiry afterwards, so you can check it took effect.
Be careful which account you lock. If you lock the only user with sudo rights, or the one you are logged in as, you may lose access to the machine. Check that another administrator account works first. Also remove the user’s public keys from authorized_keys if they are never coming back, and stop any services or cron jobs running as that user.
Further reading: passwd(1) manual