CentOS 7 User & Group Permissions Guide

  1. Create users and groups.
  1. Create a user using the command useradd, like sudo useradd example_user.
  2. Create a group using the command groupadd, for example sudo groupadd example_group.
  1. Add users to a group:
  1. Add a user to a group using the usermod command, for example by using sudo usermod -a -G example_group example_user.
  1. Change the owner and group of a file or directory:
  1. Change the owner of a file or directory using the command chown, for example sudo chown example_user:example_group file.txt.
  2. Change the group ownership of a file or directory using the chgrp command, for example, sudo chgrp example_group file.txt.
  1. Set permissions for the file or directory.
  1. Set the permissions of a file or directory using the command chmod, for example, sudo chmod 755 file.txt.
  2. Combine the commands chown and chgrp to set permissions, like using sudo chown example_user:example_group file.txt && sudo chmod 755 file.txt.
  1. Check the current user’s and group’s permissions.
  1. Check the groups that the current user belongs to using the command id, such as id.
  2. To check the groups of the current user, use the command “groups”, for example: groups.

Please note that configuring user and group permissions requires root or sudo privileges.

bannerAds