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 johnsudo 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 developerssudo 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 filenamechmod g-w filenamechmod o=rx filename
Numeric mode:
bashchmod 755 filenamechmod 644 filename
Practical Scenarios
Creating a New User and Assigning to a Group
Changing File Ownership and Permissions
Comprehensive Example
bashsudo useradd alicesudo passwd alicesudo groupadd engineerssudo usermod -aG engineers alicegroups alicetouch project.txtsudo chown alice:engineers project.txtchmod 664 project.txtls -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.
Top comments (0)