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
Steps to create a Nextcloud group 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 - Create the group.
$ 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.
- Inspect the group record.
$ sudo -E -u www-data php occ group:info editors - groupID: editors - displayName: editors - backends: - Database - Add an existing user to the group.
$ 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 - Verify the group membership.
$ sudo -E -u www-data php occ group:list editors - editors: - adaUse --output=json_pretty when another script needs to consume the group list.
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.