GICT knowledge base
How to Add and Remove Users Safely
Published
Managing user accounts is one of the most critical responsibilities for any system administrator or IT professional. Ensuring that users have the correct level of access, and that accounts are removed safely when no longer needed, protects sensitive information and upholds the integrity of your systems. Whether you operate a Linux, macOS, or Windows environment, understanding safe user management practices enables you to secure resources, maintain compliance, and prevent unauthorized access.
This article provides a comprehensive guide to adding and removing user accounts safely, covering not only the technical steps but also the policies and best practices that underpin secure user management. By the end of this guide, you will understand how to create and remove accounts, assign permissions, manage user data, and audit user activity following industry standards and organizational requirements.
Prerequisites
- Administrative privileges (root or sudo for Unix/Linux, Administrator for Windows)
- Familiarity with your operating system’s command-line interface or graphical tools
- A clear understanding of your organization’s user access and security policies
- Backup solutions for important user data
Introduction to User Account Management
User accounts serve as the foundation for authentication and authorization on any system. Each account represents an individual identity, enabling you to assign permissions, track activities, and control access to files, services, and applications. Proper user management ensures that only authorized individuals can interact with your resources, reducing the risk of security breaches and operational disruption.
Safe user management involves more than simply running commands. You must also consider how users are created, what permissions you assign, how their data is handled, and what happens when they leave your organization or no longer require access. The following sections cover all aspects of safe user management, including technical procedures, security tips, and compliance considerations.
Add a New User Account
Step 1: Plan the Account
Before you create a new user, determine:
- The purpose of the account (employee, contractor, service account, etc.)
- Required privileges (standard user, administrator, specific group membership)
- Naming conventions to ensure consistency and prevent confusion (e.g., first initial + last name)
Step 2: Create the User (Linux/Unix)
Open your terminal.
Add the new user:
$ sudo adduser username
Replace username with the actual account name. The system prompts for a password and optional details such as the user’s full name.
Ensure the password meets your organization’s complexity requirements.
Assign the user to necessary groups (for example, sudo for administrative access):
$ sudo usermod -aG groupname username
Replace groupname with the appropriate group.
Verify the account and group membership:
$ id username
Step 3: Create the User (Windows)
Open the Control Panel or Settings app.
Navigate to Accounts > Family & other users.
Click Add someone else to this PC.
Enter the user’s information and assign the account type (Standard or Administrator).
Set a strong password.
Alternatively, use the command prompt or PowerShell:
C:\> net user username /add C:\> net localgroup Administrators username /add
Step 4: Configure Default Settings
After creating a user, set up their environment:
- Set a strong, unique password.
- Assign a default shell (Linux) or configure login scripts.
- Set up home directories with appropriate permissions.
- Apply disk quotas if you need to control storage usage.
Example: Set Disk Quota (Linux)
Enable quotas on the filesystem. Assign quota for the user: $ sudo edquota -u username
Step 5: Communicate Details
Provide the new user with their credentials and instructions for first login, password change, security policies, and support contacts.
[!NOTE] Avoid sharing passwords over unsecured channels. Use direct communication or secure password managers when possible.
Remove a User Account Safely
Removing user accounts is as important as adding them, especially when employees leave or roles change. Failing to remove or disable accounts can leave systems vulnerable to unauthorized access.
Step 1: Identify Accounts for Removal
Regularly review all user accounts. Identify inactive or unnecessary accounts. Confirm with managers or HR before proceeding with deletion.
Step 2: Notify the User and Back Up Data
Inform the user (if appropriate) and relevant stakeholders. Back up important data from the user’s home directory or profile. Inventory files and emails that may be needed for business continuity.
Example: Back Up Home Directory (Linux)
$ sudo tar -czvf /backup/username-home.tar.gz /home/username
Example: Back Up Profile (Windows)
Copy the user’s profile directory, usually located at C:\Users\username, to a secure backup location.
Step 3: Disable the Account (Recommended First Step)
Disabling allows you to revoke access while preserving data for review or transfer.
Linux/Unix
$ sudo usermod --lock username
or
$ sudo passwd -l username
Windows
Open the Computer Management console. Navigate to Local Users and Groups > Users. Right-click the account and choose Properties. Check Account is disabled.
Step 4: Remove the Account
After verification and backup, proceed with account removal.
Linux/Unix
Remove the user but keep the home directory:
$ sudo deluser username
Remove the user and delete the home directory:
$ sudo deluser --remove-home username
Remove a user’s group if no longer needed:
$ sudo delgroup groupname
Windows
Delete from the Local Users and Groups interface.
Or use the command prompt:
C:\> net user username /delete
[!WARNING] Deleting a user with the --remove-home or /delete option is irreversible. Ensure all necessary data is backed up before proceeding.
Manage User Permissions and Groups
Proper group and permission management is essential for maintaining security and operational efficiency. Assign only the permissions necessary for each user.
Add Users to Groups
Assign users to groups to grant access to shared resources:
$ sudo usermod -aG groupname username
On Windows, use:
C:\> net localgroup groupname username /add
Remove Users from Groups
Remove group membership to revoke access:
$ sudo gpasswd -d username groupname
On Windows:
C:\> net localgroup groupname username /delete
Review Permissions Regularly
Periodically audit group membership and user permissions. Use groups username (Linux) or the Local Users and Groups interface (Windows) to review assignments.
Audit and Monitor User Activity
Maintaining a secure system requires continuous monitoring of user activity and periodic reviews of account status.
Track Logins and Activity
View last login times (Linux):
$ lastlog
Review user activity logs:
- On Linux, check
/var/log/auth.logor/var/log/secure - On Windows, use the Event Viewer to inspect Security logs
List All User Accounts
List all users (Linux):
$ cut -d: -f1 /etc/passwd
List all users (Windows):
C:\> net user
Detect Orphaned or Unused Accounts
Compare the list of users with your HR or personnel records. Disable or remove accounts that are no longer necessary.
[!NOTE] Regular audits help you identify potential security risks and maintain compliance with organizational policies.
Handle User Data Responsibly
When adding or deleting users, handle all personal data in compliance with privacy regulations and company policy.
- Back up critical files before account deletion.
- Transfer ownership of shared files to appropriate team members.
- Securely erase sensitive files when no longer needed.
Secure File Deletion (Linux)
$ shred -u /home/username/importantfile
Secure File Deletion (Windows)
Use built-in tools like Cipher or third-party secure deletion utilities.
Disable, Not Delete, for Temporary Inactivity
If a user will return or you need to maintain their data temporarily, disable the account rather than delete it.
Linux/Unix
$ sudo usermod --lock username
Windows
Disable the account in Local Users and Groups as described earlier.
Automate and Document User Management
Automate user account management where possible to reduce errors and enhance efficiency.
- Use configuration management tools (Ansible, Puppet, Chef) for bulk account creation or removal.
- Maintain clear documentation for every user account change, including purpose, date, and approving authority.
- Implement ticketing systems for user account requests to ensure accountability.
Best Practices for Secure User Management
- Apply the principle of least privilege: Grant only the minimum permissions necessary.
- Enforce password policies: Require complex passwords and regular changes.
- Enable multi-factor authentication (MFA) where possible.
- Remove or disable accounts immediately upon employment termination or role change.
- Use unique accounts for each user; never share credentials.
- Audit user access regularly and reconcile with personnel lists.
- Keep software and system security patches up to date.
Special Considerations for Remote and Automated Users
Service Accounts
Create service accounts specifically for automated processes or applications. Restrict service account permissions to the necessary minimum. Rotate credentials for service accounts regularly and monitor their usage.
Remote Users
Set up VPN, SSH keys, or other secure access methods for remote users. Remove remote access promptly when no longer required.
Addressing Common User Management Challenges
Forgotten Passwords
Provide a secure password reset process. Never send plain-text passwords via email.
Locked Accounts
Monitor for account lockouts (which may indicate unauthorized access attempts). Unlock accounts only after verifying the user’s identity.
Orphaned Files
Use file auditing tools to locate files with no valid owner. Transfer or archive orphaned files before deleting user accounts.
Conclusion
Effective user management is crucial for system security, compliance, and operational efficiency. By following a structured approach to adding and removing users, you minimize the risk of unauthorized access, data loss, and operational disruption. Always back up user data, use account disabling before deletion when appropriate, and audit regularly to ensure your environment remains secure. Applying these best practices enables you to maintain a safe, compliant, and well-organized system for all users.
[!NOTE] For more information on secure user management, consult your platform’s official documentation and your organization’s security policy.
