• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

RHEL 7 – RHCSA Notes : Create, delete, and modify local groups and group memberships.

by admin

RHEL 7 – RHCSA Notes (Cheat Sheets)

Group administration

– Use the groupadd command to add a new group :

# groupadd [options] group_name

– Use the groupmod command to modify an existing group :

# groupmod [options] group_name

– Use groupdel to delete the group. You can remove a group even if there are users in the group. But you can not remove the primary group of an existing user. You must remove the user before removing the group.

# groupdel group_name

– Use the gpasswd command to administer the groups :

# gpasswd [options] group_name

For example : to add user test in group student –

# gpasswd -a test student

groups command

The groups command displays the group the user belongs to. For example the user oracle as shown below belongs to multiple groups which can be displayed using the groups command :

# groups oracle
oracle : oinstall dba asm asmdba oper
# grep oracle /etc/group
oinstall:x:5004:oracle
dba:x:5005:oracle
asm:x:5006:oracle
asmdba:x:5007:oracle
oper:x:5008:oracle

newgrp command

The newgroup command executes a new shell and changes a user’s real group information. For example,
Before executing newgrp command

$ id
uid=5004(oracle) gid=5004(oinstall) groups=5004(oinstall),5005(dba) ...
$ ps
   PID TTY          TIME CMD
106591 pts/0    00:00:00 bash
106672 pts/0    00:00:00 ps

After executing newgrp command

$ newgrp dba

Note the gid for the user has changed to that of the student group :

$ id
uid=5004(oracle) gid=5005(dba) groups=5005(dba),5004(oinstall) ...

Also note that a new shell has been executed.

$ ps
   PID TTY          TIME CMD
106591 pts/0    00:00:00 bash
106231 pts/0    00:00:00 bash
106672 pts/0    00:00:00 ps
Note : you can only change your real group name to a group that you are member of.

Filed Under: CentOS/RHEL 7, RHCSA notes

Some more articles you might also be interested in …

  1. Beginners Guide to “journalctl” – How To Use Journalctl to View and Manipulate Systemd Logs
  2. A File Is Claimed to Be Disappearing – How to monitor a file for deletion in Linux
  3. “Logical volume vg/lv contains a filesystem in use” – while removing LVM filesystem
  4. CentOS / RHEL 7 : Chrony V/s NTP (Differences Between ntpd and chronyd)
  5. Server Application Getting “connection refused” From Remote Servers [due to firewalld or iptables] – CentOS/RHEL 7
  6. How To Enforce Password Complexity For All Users, Including “root”, By Using the “passwdqc” PAM Module CentOS/RHEL
  7. How to Use Iperf to Test Network Performance in Linux
  8. Input/Output Errors During XFS Filesystem Access In CentOS/RHEL 7
  9. CentOS/RHEL: /tmp mount point not automatically mounting when added in /etc/fstab
  10. CentOS/RHEL: “id” command doesn’t list the Group Name against GID for LDAP Users

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright