CentOS 7 User & Group Permissions Guide
- Create users and groups.
- Create a user using the command useradd, like sudo useradd example_user.
- Create a group using the command groupadd, for example sudo groupadd example_group.
- Add users to a group:
- Add a user to a group using the usermod command, for example by using sudo usermod -a -G example_group example_user.
- Change the owner and group of a file or directory:
- Change the owner of a file or directory using the command chown, for example sudo chown example_user:example_group file.txt.
- Change the group ownership of a file or directory using the chgrp command, for example, sudo chgrp example_group file.txt.
- Set permissions for the file or directory.
- Set the permissions of a file or directory using the command chmod, for example, sudo chmod 755 file.txt.
- Combine the commands chown and chgrp to set permissions, like using sudo chown example_user:example_group file.txt && sudo chmod 755 file.txt.
- Check the current user’s and group’s permissions.
- Check the groups that the current user belongs to using the command id, such as id.
- 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.