zmprov Command: Create a Zimbra Account in 5 Easy Steps

The zmprov command is the Zimbra tool that creates, changes and deletes accounts from the command line. This article explains how to use it to create an account with attributes, change its password, edit attributes with the + and - prefixes, and add aliases. The first version was a list of commands with no explanation, so this rewrite checks every command against the Zimbra Administrator Guide.

How this article was written: there is no Zimbra server in the author's lab, so nothing here is a fresh test run. The commands come from the original post, where an operator ran them on a real Zimbra server, and every syntax rule is taken from the Administrator Guide (Appendix A, zmprov command). The only output shown is the one from that original post.

Before you run the zmprov command

Run all Zimbra command-line tools as the zimbra user (su - zimbra). The guide also says that commands are case-sensitive and must be typed in lower case, and that -h shows the usage of any tool, for example zmprov -h. The tools live in /opt/zimbra/bin.

Most operations of the zmprov command have a long name and a short name, so these two lines are the same command, copied from the guide:

zmprov createAccount joe@domain.com test123
zmprov ca joe@domain.com test123

The syntax of the create command is createAccount (ca) {name@domain} {password} [attr1 value1].... Curly brackets mean required values, square brackets mean optional ones, and an attribute name that contains spaces must be put in double quotes. Notice that the password is a required argument, so a create command without it fails.

Create an account with attributes

The simplest form creates the account with a password and one attribute, as in the guide: zmprov ca joe@domain.com test123 displayName JSmith. You can add as many attribute value pairs as you need. The original post used this command for a user with a last name, a full name, a display name and a mailbox server:

zmprov ca huupv10@mail.huuphan.local PASSWORD sn 'huupv' cn 'Huu, Phan Van' displayName 'Huu, Phan Van (IT)' zimbraMailHost mail.huuphan.local

Each pair has a meaning: sn is the last name, cn the full name, displayName the name shown in the address book and zimbraMailHost the server that stores the mailbox. Replace PASSWORD with a strong password of your own; the original post used a weak numeric example, which you should never copy. The guide's own samples use test123 only to show the syntax.

Before you create the account, you can test a password with zmprov cps {name@domain | id} {password} (checkPasswordStrength). The guide warns that this command does not check the password age or history, so a pass here does not guarantee that the policy will accept the password later.

Read, change and delete accounts

These short forms of the zmprov command, all from the guide's account table, cover the daily work:

  • zmprov ga joe@domain.com prints one account (getAccount).
  • zmprov -l gaa lists all accounts. The guide says this command must include -l (LDAP), and that -l gaa -v domain.com adds details for one domain.
  • zmprov sp joe@domain.com test321 sets a new password (setPassword). Passwords cannot contain accented characters such as ã, é, í, ú, ü or ñ.
  • zmprov ra joe@domain.com joe23@domain.com renames an account. After a rename the guide tells you to run a full backup for the new name: zmbackup -f -s <servername.com> -a <newaccountname@servername.com>.
  • zmprov da joe@domain.com deletes an account (deleteAccount), so double-check the address first.

To print a single attribute with the zmprov command, put its name after the account. This is the original post's example and its real output:

$ zmprov ga huupv10@mail.huuphan.local displayName
# name huupv10@mail.huuphan.local
displayName: Huu, Phan Van (IT)
zmprov command printing the displayName attribute of a Zimbra account
The zmprov command prints one attribute of an account (output from the original post).

If you only need to know whether an account is active or locked, the related guides on checking Zimbra account status and locking and unlocking an account show the status values.

Modify attributes with the zmprov command: + and -

To change a single-value attribute such as the display name, use zmprov ma (modifyAccount): zmprov ma huupv10@mail.huuphan.local displayName 'Huu, Phan Van'. Some attributes can hold several values, and for those the guide describes a prefix: use + to add a new instance without changing the existing ones, and - to remove one particular instance. The original post applied it to mail forwarding:

zmprov ma huupv10@mail.huuphan.local +zimbraMailForwardingAddress user@example.com
zmprov ma huupv10@mail.huuphan.local -zimbraMailForwardingAddress user@example.com

The first line adds one forwarding address and the second removes exactly that one, so forwarding addresses you added earlier stay in place. Without the plus sign you would replace the value instead of adding to it, which is the most common cause of lost settings. The guide also uses zmprov ma to put an account into maintenance mode (zmprov ma joe@domain.com zimbraAccountStatus maintenance), which stops new mail delivery, and back to active afterwards.

To learn what an attribute is and whether changing it needs a restart, run zmprov desc -a <attributename>. The guide says a requiresRestart value appears in the output when a restart is needed.

Aliases, class of service and distribution lists

The same zmprov command covers the objects around an account. From the guide's tables: zmprov aaa joe@domain.com joe.smith@engr.domain.com adds an alias, zmprov raa with the same arguments removes it, and zmprov sac joe@domain.com FieldTechnician assigns a class of service. Distribution lists use zmprov cdl needlepoint-list@domain.com to create one and zmprov adlm needlepoint-list@domain.com singer23@mail.free.net to add a member.

Common mistakes with the zmprov command

  • Running the zmprov command as root instead of the zimbra user.
  • Forgetting -l with gaa, or typing a command in upper case.
  • Using ma without a + prefix on a multi-value attribute and so replacing the old values.
  • Leaving a sample password in the command and in your shell history. Choose a unique password and clear the history line if others share the server.
  • Skipping the backup after a rename.

FAQ

Where do I find every zmprov command option? In Appendix A of the Zimbra Administrator Guide, which has one table per topic: accounts, calendar resources, domains, COS, servers, configuration, distribution lists and more.

Is the Admin Console better than the command line? The guide says that provisioning and managing accounts should generally be done from the Administration Console; use the zmprov command for scripts, bulk work and tasks the console cannot do.

Comments

Popular posts from this blog

Linux Desktop Frozen? 5 Proven Fixes Before a Hard Reboot

Minecraft Bedrock on Linux: 4 Proven Ways to Play in 2026

DXVK in Wine on Linux: 7 Easy Setup Steps, Tested