Local user accounts in Nextcloud give each person a separate file space, sharing identity, app settings, and activity trail. Creating the account from the server shell fits onboarding, recovery preparation, or scripted provisioning when the web Users page is not the right surface.
The occ user command creates database-backed accounts through the installed Nextcloud application. Run it as the web-server user from the installation directory so account records, generated files, and data-directory ownership stay consistent with the running service.
This path is for local accounts managed by Nextcloud itself. For LDAP, SAML, or another external identity provider, create the person in that identity system first and let Nextcloud import or map the account instead of assigning a separate local password.
Related: How to run Nextcloud occ commands
Related: How to create a Nextcloud admin user
Related: How to reset a Nextcloud user password with occ
Steps to create a Nextcloud user with occ:
- Open a shell on the Nextcloud server and enter the installation directory.
$ cd /var/www/nextcloud
- Confirm occ can read the installed instance.
$ sudo -E -u www-data php occ status - installed: true ##### snipped ##### - maintenance: false ##### snipped #####
www-data is the HTTP user on Debian and Ubuntu. Use the web-server user that owns the Nextcloud files when the instance runs under a different account.
Related: How to run Nextcloud occ commands - Mark the password variable for export.
$ export OC_PASS
- Read the new account password into the variable.
$ read -rs OC_PASS
Type the temporary password at the silent prompt. No characters are displayed while read stores the value.
- Create the local user and assign the group.
$ sudo -E -u www-data php occ user:add --password-from-env --display-name="Ada Lovelace" --group=editors ada The user "ada" was created successfully Display name set to "Ada Lovelace" User "ada" added to group "editors"
--password-from-env reads OC_PASS, and --group can be repeated for more groups. Check the group name before running the command because Nextcloud automatically creates groups that do not already exist.
- Remove the temporary password variable from the shell.
$ unset OC_PASS
- Set the user's email address.
$ sudo -E -u www-data php occ user:setting ada settings email "ada@example.com"
Use --email on user:add only when welcome email delivery is configured and wanted. Nextcloud sends a welcome email by default when an email address is supplied during account creation.
- Verify the new account record.
$ sudo -E -u www-data php occ user:info ada - user_id: ada - display_name: Ada Lovelace - email: ada@example.com - cloud_id: ada@cloud.example.com - enabled: true - groups: - editors - quota: none - storage: ##### snipped ##### - first_seen: never - last_seen: never - user_directory: /var/www/nextcloud/data/ada - backend: Database - Test a login through WebDAV with the temporary password.
$ curl --silent --show-error --user ada --request PROPFIND --header "Depth: 0" --output /dev/null --write-out "%{http_code}\n" https://cloud.example.com/remote.php/dav/files/ada/ Enter host password for user 'ada': 207HTTP status 207 means the account authenticated and the WebDAV collection answered. Use the browser sign-in page instead when two-factor authentication, device-specific app passwords, or a login policy blocks password-only WebDAV access.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.