SYS: Create, delete, and modify local groups and group memberships.

Share this link

Note: This is an RHCSA 7 exam objective.

To create a group without any associated user (here grp), type:

# groupadd grp

To create a group without any associated user (here grp) with a given GID, type:

# groupadd -g GID grp

To change the name of a group (here from grp to gr), type:

# groupmod -n gr grp

To remove a group without any associated user (here grp), type:

# groupdel grp

To change the GID of a group (here grp), type:

# groupmod -g GID grp

To add a secondary group (here grp) to a user account (here user), type:

# usermod -aG grp user

or:

# gpasswd -a user grp

To remove a user (here user) from a secondary group (here grp), type:

# gpasswd -d user grp

Note: This doesn’t work on the primary group.

To get the list of the members of a given group (here mail), type:

# groupmems -g mail -l
postfix
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.00 out of 5)
Loading...
2 comments on “SYS: Create, delete, and modify local groups and group memberships.
  1. fernandezcuesta says:

    -n flag missing:

    To change the name of a group (here from grp to gr), type:

    — # groupmod gr grp
    ++ # groupmod -n gr grp

Leave a Reply

RHCSA7: Task of the day

Allowed time: 15 minutes.
Get an iso image of CentOS 7 (or a DVD) and set up a local repository.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a NFS server that exports the /opt directory in read-only mode.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...

Archives