Learn the difference between Windows net user and PowerShell’s Remove-LocalUser, plus a handy command-line user management cheat sheet for Windows, Linux, and macOS.
Managing Users from the Terminal: Windows vs. Linux vs. macOS
When managing a computer, clicking through graphical settings menus is fine, but using the command line is faster, scriptable, and often the only option on headless servers or remote SSH sessions.
The catch? Every operating system speaks a slightly different dialect.
Whether you’re spinning up a quick test user or cleaning up an old account, here is a quick-reference guide and tutorial on how user management commands compare across Windows, Linux, and macOS.
The Cheat Sheet: User Management Commands
| Operation | Windows (CMD) | Windows (PowerShell) | Linux (Ubuntu, Debian, etc.) | macOS |
|---|---|---|---|---|
| Create User | net user <user> <pass> /add |
New-LocalUser -Name "<user>" |
sudo useradd <user>or sudo adduser <user> |
dscl . -create /Users/<user> |
| Delete User | net user <user> /delete |
Remove-LocalUser -Name "<user>" |
sudo userdel <user> |
dscl . -delete /Users/<user> |
| List Users | net user |
Get-LocalUser |
cut -d: -f1 /etc/passwd |
dscl . -list /Users |
| Change Password | net user <user> <newpass> |
Set-LocalUser -Name "<user>" |
sudo passwd <user> |
dscl . -passwd /Users/<user> <pass> |
Quick Tutorials by OS
1. Windows (CMD & PowerShell)
Windows gives you multiple command-line options. Note that net user runs in the classic Command Prompt (cmd.exe), while New-LocalUser and Remove-LocalUser are built for PowerShell. Regardless of which tool you use, they talk to the same local Windows user database.
Create a user (CMD):
net user TestUser MyPassword123 /add
Delete the user (PowerShell):
Remove-LocalUser -Name "TestUser"
2. Linux (Ubuntu / Debian / CentOS)
Linux relies heavily on utilities like useradd for low-level creation and adduser for a more interactive, guided setup. Administrative privileges (sudo) are required.
Create a user:
sudo adduser testuser
Delete a user (and their home directory):
sudo userdel -r testuser
3. macOS
macOS handles local directory services via dscl (Directory Service Command Line). While it looks intimidating, it allows programmatic control over user accounts on a Mac.
Create a user:
sudo dscl . -create /Users/testuser
sudo dscl . -create /Users/testuser UserShell /bin/bash
Delete a user:
sudo dscl . -delete /Users/testuser
Wrapping Up
No matter your OS, the command line gives you flexibility. In Windows, don’t sweat whether you use net user or PowerShell’s Remove-LocalUser—they are different tools for managing local user accounts.




Geef een reactie