Frequently Asked Question

occ user (user management)
Last Updated 3 hours ago

occ user (user management)

occ user Commands – Quick Reference

The occ user sub‑command is used to manage Nextcloud users directly from the command line. It is especially handy for administrators who need to script bulk operations or troubleshoot user‑related issues without using the web UI.

1. List all users

Command: occ user:list

  • Shows a table with every user account, including username, display name, user ID and account status.
  • Useful for a quick audit or to verify that a particular account exists.

2. Show detailed user information

Command: occ user:info <username>

  • Replaces the generic occ user:info placeholder with the actual username you want to inspect.
  • Returns full details such as email address, groups, quota, and whether the account is disabled.

3. Add a new user

Command: occ user:add <username> --display-name="Display Name" --email="user@example.com"

  • Creates a new account with the supplied username, display name and email.
  • Optional flags let you set a password at creation time (--password="plain"), assign groups (--group="admin"), or enable/disable the account (--no-password to force password reset on first login).

4. Delete a user

Command: occ user:delete <username>

  • Permanently removes the specified user and all of their data from the Nextcloud instance.
  • The operation cannot be undone; ensure you have a backup if the deletion is accidental.

5. Disable a user

Command: occ user:disable <username>

  • Locks the account so that the user can no longer log in, while keeping the record in the database.
  • The user remains visible in occ user:list and occ user:info.

6. Enable a disabled user

Command: occ user:enable <username>

  • Re‑activates a previously disabled account, allowing normal login again.

7. Reset a user’s password

Command: occ user:resetpassword <username>

  • Triggers an interactive password reset flow. The command prompts for a new password and confirmation.
  • Alternatively, you can supply the password directly with --password="newpass" (use with caution).

8. Show user count report

Command: occ user:report

  • Prints a short summary that includes the total number of users, active users, disabled users and a breakdown by group if applicable.
  • Helpful for quick capacity checks or to verify that bulk import scripts have completed correctly.

Practical Tips

  sudo -u www-data php occ user:list
  occ user:list --output=json | jq -r '.[] | select(.group != "admin") | .username' | xargs -I{} occ user:disable {}
  • Run as the web‑server user (often www-data or http) to avoid permission errors:
  • Combine with other occ commands for bulk operations, e.g., to disable all users not in a specific group:
  • Check the Nextcloud documentation for additional flags and advanced usage (e.g., --skip-existing when adding users).

If any of the commands return an error, verify that:

  1. The Nextcloud installation directory is correct.
  2. The PHP environment has the required extensions (e.g., intl, gd).
  3. The database credentials in config/config.php are valid.

These steps will ensure the occ user commands work reliably in your environment.

This FAQ was generated and/or edited by GAIN, GENs Artificial Intelligence Network and should not be considered 100% accurate. Always check facts and do your research, things change all the time. If you are unsure about any information provided, please raise a support ticket for clarification.
This website relies on temporary cookies to function, but no personal data is ever stored in the cookies.
OK
Powered by GEN UK CLEAN GREEN ENERGY

Loading ...