There is a restricted area in a site hosted by Apache HTTPD, which requires users to authenticate against the file /srv/www/security/site-passwd.

Which command is used to CHANGE the password of existing users, without losing data, when Basic authentication is being used?

A.

htpasswd -c /srv/www/security/site-passwd user

B.

htpasswd /srv/www/security/site-passwd user

C.

htpasswd -n /srv/www/security/site-passwd user

D.

htpasswd -D /srv/www/security/site-passwd user

題解

選項 A,「htpasswd」指令的「-c」參數會建立新的設定檔,所以會將之前的設定覆蓋掉。

選項 B,正確答案。

選項 C,「htpasswd」指令的「-n」參數會將結果輸出到標準輸出,而不是更新檔案,所以無法修改密碼檔中的密碼。

選項 D,「htpasswd」指令的「-D」參數用來刪除指定的使用者。