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.

Steps to create a Nextcloud group with occ:

  1. Open a shell on the Nextcloud server and enter the installation directory.
    $ cd /var/www/nextcloud
  2. 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

  3. 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.

  4. Inspect the group record.
    $ sudo -E -u www-data php occ group:info editors
      - groupID: editors
      - displayName: editors
      - backends:
        - Database
  5. 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

  6. Verify the group membership.
    $ 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.