Master User & Group Management Across Linux and Windows!

Listen to this Post

Managing users and groups is a fundamental task for system administrators, whether working on Linux or Windows systems. This guide provides a comprehensive comparison of commands for both operating systems, helping you streamline your workflow in mixed environments.

User Management

Linux Commands

1. Create a User:

sudo useradd username 
sudo passwd username 

2. Delete a User:

sudo userdel username 

3. Modify User Attributes:

sudo usermod -aG groupname username # Add user to a group 
sudo usermod -s /bin/bash username # Change default shell 

4. Switch User:

su - username 

Windows Commands

1. Create a User:

New-LocalUser -Name "username" -Password (ConvertTo-SecureString "password" -AsPlainText -Force) 

2. Delete a User:

Remove-LocalUser -Name "username" 

3. Modify User Attributes:

Add-LocalGroupMember -Group "groupname" -Member "username" 

4. Switch User:

  • Use `RunAs` or log out and log in as another user.

Group Management

Linux Commands

1. Create a Group:

sudo groupadd groupname 

2. Delete a Group:

sudo groupdel groupname 

3. List Group Members:

getent group groupname 

Windows Commands

1. Create a Group:

New-LocalGroup -Name "groupname" 

2. Delete a Group:

Remove-LocalGroup -Name "groupname" 

3. List Group Members:

Get-LocalGroupMember -Group "groupname" 

Permissions & Ownership

Linux Commands

1. Change File Ownership:

sudo chown username:groupname filename 

2. Change File Permissions:

chmod 755 filename # rwxr-xr-x 

Windows Commands

1. Change File Ownership (via CMD):

[cmd]
takeown /f filename /U username
icacls filename /grant username:F
[/cmd]

Password Policies

Linux Commands

1. Set Password Expiry:

sudo chage -M 90 username # Expires in 90 days 

Windows Commands

1. Set Password Expiry:

Set-LocalUser -Name "username" -PasswordNeverExpires $false 

You Should Know:

  • Linux: Use `id username` to check user groups.
  • Windows: Use `net user username` to see user details.
  • Linux: `visudo` safely edits the sudoers file.
  • Windows: `gpupdate /force` refreshes Group Policy settings.

What Undercode Say:

Mastering user and group management is essential for maintaining secure and efficient systems. Whether you’re working with Linux or Windows, understanding these commands ensures smooth administration. Automation with scripts (bash or PowerShell) can further enhance productivity.

Expected Output:

User 'testuser' created successfully. 
Group 'developers' modified. 
File permissions updated to 755. 

For more in-depth tutorials, check:

References:

Reported By: Saqlain Khan – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image