Users and Groups in CentOS7#
root: Root User
Configuration Files for Users and Groups#
/etc/passwd
: Users
Format:
Username:Password:UID:GID:User Directory:Shell Program
/etc/group
: Groups
About Groups in Linux:#
- Private Group: Created along with the user, named after the user
- Public Group: Custom created
About Users in Linux:#
- Root User: Highest authority as root
- Regular User: Can use the Linux system, but with limited permissions
Related Commands for Linux Users and Groups#
Add User: useradd
Set User Password: passwd
About User Directory: By default, when adding a user, a directory with the same name as the user will be created in /home
Delete User: userdel username -r (delete user directory simultaneously)
Add Group: groupadd
Delete Group: groupdel
For example: Add users tom and mike; password 123; create a public group student; add tom and mike to the student group
usermod -G groupname username # Move user to group
or
gpasswd -a username groupname # Add user to group
gpasswd -d username groupname # Remove user from group