Command
sudo htpasswd -c /etc/apache2/.htpasswd username
Explanation
Creates or updates password file for basic authentication.
Examples
Create new password file
sudo htpasswd -c /etc/apache2/.htpasswd username
Add another user
sudo htpasswd /etc/apache2/.htpasswd anotheruser