User/Group Management and Permissions/Ownership in Linux

Linux, as a multi-user operating system, requires effective user and group management to maintain system security and control access to resources. This document outlines key concepts and practices in user/group management and file permissions/ownership.
User Management
Types of Users
Root User: Superuser with unrestricted system access. Home directory:
/root.Regular Users: Non-privileged users with home directories in
/home/username.
Creating Users
bashsudo useradd john
sudo passwd john
User Configuration Files
/etc/passwd: User account information/etc/shadow: Encrypted passwords and account expiration data/etc/group: Group information
Group Management
Groups facilitate managing permissions for multiple users simultaneously.
Creating Groups and Adding Users
bashsudo groupadd developers
sudo usermod -aG developers john
Key Management Commands
useradd: Add new userpasswd: Set/change user passwordusermod: Modify user accountgroupadd: Add new groupgroups: Display user's group membershipsdeluser: Delete userdelgroup: Delete group
Permissions and Ownership
Linux uses a permission model to control file and directory access.
File Ownership
Owner: User who owns the file
Group: Group that owns the file
Change ownership:
bashsudo chown user:group filename
File Permissions
Permissions are represented as:
text-rwxr-xr--
First character: File type
Next three: Owner permissions
Following three: Group permissions
Last three: Others' permissions
Permissions include:
r: Readw: Writex: Execute
Changing File Permissions
Using chmod command:
Symbolic mode:
bashchmod u+rwx filename
chmod g-w filename
chmod o=rx filename
Numeric mode:
bashchmod 755 filename
chmod 644 filename
Practical Scenarios
Creating a New User and Assigning to a Group
bashsudo useradd john sudo passwd john sudo groupadd developers sudo usermod -aG developers john groups johnChanging File Ownership and Permissions
bashtouch example.txt sudo chown john:developers example.txt chmod 754 example.txt ls -l example.txt
Comprehensive Example
bashsudo useradd alice
sudo passwd alice
sudo groupadd engineers
sudo usermod -aG engineers alice
groups alice
touch project.txt
sudo chown alice:engineers project.txt
chmod 664 project.txt
ls -l project.txt
This comprehensive guide provides a solid foundation for managing users, groups, and file permissions in Linux environments, essential for maintaining system security and access control.