Warning: Be careful with the switches because it's easy to overwrite existing configuration.
To edit an Apache authentication file - referred to in these examples as [filename] - use the htpasswd or htpasswd2 command. You will be prompted to enter a password if you do not supply one. The [filename] is normally .htpasswd, depending on configuration, but it can vary according to the application that is using Apache authentication. For example, see the page about adding/removing Subversion (svn) users.
Add a user:
htpasswd [filename] [username]
Or:
htpasswd2 [filename] [username]
Adding the -c switch will create the .htaccess file:
htpasswd2 -c [filename] [username]
You can specify the password instead of being prompted for it:
htpasswd2 -cb [filename] [username] [password]
Delete user:
htpasswd2 -d [filename] [username] [password]
Edit user:
htpasswd2 -s [filename] [username] [password]