If you want to work as a system administrator, you need to know how to manage users and group administration. Both Linux and Windows have their distinct tools and processes for managing users and groups. In this blog, we will be highlighting the features and methods of managing users and groups both in Windows and Linux servers.
Linux: User and Group Administration
As a system administrator, you need to know the command line tools for managing users and groups. In the below article, we will be discussing the key commands that need to be learned for the basic operation of managing users and groups.
Understanding the “/etc/passwd” file:
The /etc/passwd file contains essential information about user accounts. Each line represents a user, with fields separated by colons (:):
- Username
- Password Info (stored in /etc/shadow)
- User ID (UID)
- Group ID (GID)
- User’s Comment
- Home Directory
- Shell
For example:
tarek:x:1001:1001::/home/tarek:/bin/bash
Common User Management Commands
- Adding Users:
useradd tarek
tail /etc/passwd
Setting Passwords:
passwd mahfuz
grep 'mahfuz\|murshid' /etc/shadow
Modifying Users:
usermod -G trainer tarek # Modify existing user
useradd -G trainer belal # Add new user to group
usermod -d /newhome/roman roman # Change home directory
usermod -s /sbin/nologin mahfuz # Change user shell
Deleting Users:
userdel tarek
userdel -r tarek # Delete user with home directory
Common Group Management Commands
Adding Groups:
groupadd trainer
groupadd staff
Modifying Groups:
gpasswd -M mahfuz,murshid trainer # Add multiple users to a group
groupmod -n faculty trainer # Change group name
Deleting Groups:
groupdel staff
User and Group Information Files
- /etc/passwd: Contains user account information.
- /etc/shadow: Stores secure user password data.
- /etc/group: Holds group information.
- /etc/gshadow: Secure group password data.
Working with Sudo
The sudo command allows permitted users to execute commands as the superuser or another user, as specified by the security policy in /etc/sudoers:
visudo
Example configuration for user rumon to run all commands:
rumon ALL=(ALL) ALL
Windows: User and Group Administration:
The best facility that Windows provides is the graphical interface and managing everything using the graphical control panel. Below we will be discussing a few key aspects and tools to manage Users and Groups in Windows both using a graphical view and command prompt or PowerShell:
User Management
Adding Users:
-
- Open Control Panel > User Accounts > Manage another account > Add a new user.
- Alternatively, use the Command Prompt or PowerShell:
net user tarek /add
Setting Passwords:
-
- Use the Control Panel or Command Prompt:
net user mahfuz P@ssword123
Modifying Users:
-
- Modify user properties via the Control Panel.
- Use Command Prompt or PowerShell:
net user tarek /active:no # Disable user account
Deleting Users:
-
- Control Panel > User Accounts > Manage another account > Delete the account.
- Command Prompt or PowerShell:
net user tarek /delete
Group Management
Adding Groups:
-
- Open Computer Management > Local Users and Groups > Groups > New Group.
- Command Prompt or PowerShell:
net localgroup trainers /add
Modifying Groups:
-
- Add or remove users from groups via Computer Management.
- Command Prompt or PowerShell:
net localgroup trainers mahfuz /add
Deleting Groups:
-
- Computer Management > Local Users and Groups > Groups > Delete.
- Command Prompt or PowerShell:
net localgroup trainers /delete
Tools for User and Group Management
- Local Users and Groups: You can access this section via Computer Management for managing users and groups.
- Active Directory Users and Computers: If you are in a Windows Server environment, then you need to use this tool for managing domain users and groups.
- PowerShell: A powerful scripting language for advanced users and group management.
Conclusion
For managing users and groups, both operating systems provide an extensive amount of control. In Linux, you will be able to manage the users and groups from a command line interface whereas in Windows the main difference is you will be able to manage it from a user-friendly GUI. Both platforms provide comprehensive solutions for user and group management.