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:infoplaceholder 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-passwordto 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:listandocc 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-dataorhttp) 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-existingwhen adding users).
If any of the commands return an error, verify that:
- The Nextcloud installation directory is correct.
- The PHP environment has the required extensions (e.g.,
intl,gd). - The database credentials in
config/config.phpare valid.
These steps will ensure the occ user commands work reliably in your environment.
