Group Commands

The group commands provide a range of functionality for managing ownCloud groups. This includes creating and removing groups and managing group membership. Group names are case-sensitive, so "Finance" and "finance" are two different groups.

The full list of commands is:

group
 group:add                           Adds a group
 group:add-member                    Add members to a group
 group:delete                        Deletes the specified group
 group:list                          List groups
 group:list-members                  List group members
 group:remove-member                 Remove member(s) from a group

Creating Groups

You can create a new group with the group:add command. The syntax is:

group:add groupname

This example adds a new group, called "Finance":

sudo -u www-data php occ group:add Finance
  Created group "Finance"

Listing Groups

You can list the names of existing groups with the group:list command. The syntax is:

group:list [options] [<search-pattern>]

Groups containing the search-pattern string are listed. Matching is not case-sensitive. If you do not provide a search-pattern then all groups are listed.

Options

--output=[OUTPUT]

Output format (plain, json or json_pretty, default is plain) [default: "plain"].

This example lists groups containing the string "finance".

sudo -u www-data php occ group:list finance
 - All-Finance-Staff
 - Finance
 - Finance-Managers

This example lists groups containing the string "finance" formatted with json_pretty.

sudo -u www-data php occ group:list --output=json_pretty finance
 [
   "All-Finance-Staff",
   "Finance",
   "Finance-Managers"
 ]

Listing Group Members

You can list the user IDs of group members with the group:list-members command. The syntax is:

group:list-members [options] <group>

Options

--output=[OUTPUT]

Output format (plain, json or json_pretty, default is plain) [default: "plain"].

This example lists members of the "Finance" group.

sudo -u www-data php occ group:list-members Finance
 - aaron: Aaron Smith
 - julie: Julie Jones

This example lists members of the Finance group formatted with json_pretty.

sudo -u www-data php occ group:list-members --output=json_pretty Finance
 {
   "aaron": "Aaron Smith",
   "julie": "Julie Jones"
 }

Adding Members to Groups

You can add members to an existing group with the group:add-member command. Members must be existing users. The syntax is:

group:add-member [-m|--member [MEMBER]] <group>

This example adds members "aaron" and "julie" to group "Finance":

sudo -u www-data php occ group:add-member --member aaron --member julie Finance
  User "aaron" added to group "Finance"
  User "julie" added to group "Finance"

You may attempt to add members that are already in the group, without error. This allows you to add members in a scripted way without needing to know if the user is already a member of the group. For example:

sudo -u www-data php occ group:add-member --member aaron --member julie --member fred Finance
  User "aaron" is already a member of group "Finance"
  User "julie" is already a member of group "Finance"
  User fred" added to group "Finance"

Removing Members from Groups

You can remove members from a group with the group:remove-member command. The syntax is:

group:remove-member [-m|--member [MEMBER]] <group>

This example removes members "aaron" and "julie" from group "Finance".

sudo -u www-data php occ group:remove-member --member aaron --member julie Finance
  Member "aaron" removed from group "Finance"
  Member "julie" removed from group "Finance"

You may attempt to remove members that have already been removed from the group, without error. This allows you to remove members in a scripted way without needing to know if the user is still a member of the group. For example:

sudo -u www-data php occ group:remove-member --member aaron --member fred Finance
  Member "aaron" could not be found in group "Finance"
  Member "fred" removed from group "Finance"

Deleting a Group

To delete a group, you use the group:delete command, as in the example below:

sudo -u www-data php occ group:delete Finance