2016-09-22 12:43:57 +00:00
---
title: About the etc_group Resource
2018-02-16 00:28:15 +00:00
platform: linux
2016-09-22 12:43:57 +00:00
---
# etc_group
2019-04-26 18:24:29 +00:00
Use the `etc_group` Chef InSpec audit resource to test groups that are defined on Linux and Unix platforms. The `/etc/group` file stores details about each group: group name, password, group identifier, along with a comma-separate list of users that belong to the group.
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
<br>
2018-08-09 12:34:49 +00:00
## Availability
### Installation
2019-04-26 18:24:29 +00:00
This resource is distributed along with Chef InSpec itself. You can use it automatically.
2018-08-09 12:34:49 +00:00
### Version
This resource first became available in v1.0.0 of InSpec.
2016-09-27 19:03:23 +00:00
## Syntax
2016-09-22 12:43:57 +00:00
A `etc_group` resource block declares a collection of properties to be tested:
describe etc_group('path') do
2018-02-01 10:51:12 +00:00
its('property') { should eq 'some_value' }
2016-09-22 12:43:57 +00:00
end
or:
describe etc_group.where(item: 'value', item: 'value') do
its('gids') { should_not contain_duplicates }
its('groups') { should include 'user_name' }
its('users') { should include 'user_name' }
end
where
* `('path')` is the non-default path to the `inetd.conf` file
2018-02-06 11:29:15 +00:00
* `.where()` filters for a specific item and value, to which the parameter are compared
* `.where` filter may be one or more of:
* `name: 'name'`, `group_name: 'group_name'`, `password: 'password'`, `gid: 'gid'`, `group_id: 'gid'`, `users: 'user_name'`, `members: 'member_name'`
<br>
2018-02-15 14:33:22 +00:00
## Properties
2016-09-22 12:43:57 +00:00
2018-02-06 11:29:15 +00:00
* `'gids'`, `'groups'`, and `'users'` are valid resource parameters for this resource.
2016-09-22 12:43:57 +00:00
2018-02-06 11:29:15 +00:00
<br>
2018-02-15 14:33:22 +00:00
## Examples
2017-10-03 21:35:10 +00:00
2019-04-26 18:24:29 +00:00
The following examples show how to use this Chef InSpec audit resource.
2017-10-03 21:35:10 +00:00
### Test group identifiers (GIDs) for duplicates
describe etc_group do
its('gids') { should_not contain_duplicates }
end
### Test all groups to see if a specific user belongs to one (or more) groups
describe etc_group do
its('groups') { should include 'my_group' }
end
### Test all groups for a specific user name
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe etc_group do
its('users') { should include 'my_user' }
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Filter a list of groups for a specific user
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe etc_group.where(name: 'my_group') do
its('users') { should include 'my_user' }
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Matchers
2016-09-22 12:43:57 +00:00
2018-02-16 03:07:18 +00:00
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2016-09-22 12:43:57 +00:00