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
$ cd /var/www/nextcloud
$ 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
$ export OC_PASS
$ read -rs OC_PASS
Type the temporary password at the silent prompt. No characters are displayed while read stores the value.
$ 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.
$ unset OC_PASS
$ 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.
$ 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
$ 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':
207
HTTP 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.