htdigest command in Linux with examples

htdigest” command is used to create and update password file which is used by Apache HTTPD digest authentication. Basically, it stores usernames, realm, and password of HTTP users. Before sending any sensitive information such as online shopping transactions, it confirms identity of the users.


htdigest [-c] passwdfile realm username


  • [-c]: It is used to create a passwdfile, if this file does not exists then its created and if is already exists then that file is deleted and another file is recreated.
  • passwdfile: It contains username, realm, and password of the user.
  • realm: It is a string which is visible to the users to let them know which username and password to use.
  • Username It create or updates passwdfile. If this username does not exists then a new entry is added and if it exists then the password is changed.


  • Command to create a new Apache password file and adding a new user:
    # htdigest -c httpd-pwd-file realm username 


    Here, “httpd-pwd-file” is newly created password file which adds user gfg to the file, and “systemadmin” is the realm used here.

  • Command to see Apache password file format: It is the format of the context of the password file which is created by the ht_digest command in the text file. In order to see the password file format, you need to use “cat” command with the created password file. The format is:
    username:realm name:encrypted password


    Here, httpd-pwd-file is the file created above.

  • Command to add another user to Apache password file:
    # htdigest httpd-pwd-file realm username


    Here, user nidhi is added to httpd-pwd-file in realm author. Now, the format of the password will be:

    Here, password of two users are shown as the above httpd-pwd-file has two users now.

  • Command to change password of an user:
    # htdigest httpd-pwd-file realm username


    Here, the password of the existing user can be changed.

  • Command to add users to multiple realms in password file:
    # htdigest httpd-pwd-file realm username


    This command will add user nidhi to the existing httpd-pwd-file in the realm “systemadmin”.

    Note: There will be two password entries for user nidhi as it has different realms.


  • Command to delete an user from Apache file: To delete an user from Apache file use “vi” command i.e, (vi name of password file).

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.