Nextcloud groups collect accounts under names used by shares, app restrictions, and delegated administration. Creating the group before onboarding users gives administrators a stable target for access rules instead of editing each account separately.
The server-side occ group commands create the group and manage membership from the installed Nextcloud directory. Run them as the web-server user that owns the instance so database writes and generated files stay under the same account as the web application.
Use a neutral group ID such as editors and add an existing account only after the group record exists. A membership check with group:list proves the group can be assigned without depending on the browser Users page.
Related: How to create a Nextcloud admin user
$ 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
$ sudo -E -u www-data php occ group:add editors
editors is the group ID stored by Nextcloud. Choose a name that still reads clearly in share targets, app rules, and user lists.
$ sudo -E -u www-data php occ group:info editors
- groupID: editors
- displayName: editors
- backends:
- Database
$ sudo -E -u www-data php occ group:adduser editors ada
group:adduser accepts one or more existing user IDs after the group ID. Create the account first if ada does not exist.
Related: How to create a Nextcloud user
$ sudo -E -u www-data php occ group:list editors
- editors:
- ada
Use --output=json_pretty when another script needs to consume the group list.