Users and groups on Windows¶
Exercise users-and-groups-on-windows-annex.pdf · PDF
Think of the computer at home. When you switch it on, whose account opens? Yours, or "the family's"? And can your little brother install any game he finds on it?
On most home PCs there is one account, it can do everything, and everybody uses it. That is exactly how a lot of malware gets in. In Users and groups on Linux you met UIDs, root and the group sudo. Today you meet the same ideas on Windows — with other names, other tools, and one clever trick called UAC.
What you will learn
- Tell a local account from a Microsoft account, and a standard user from an administrator
- Match Linux ideas to Windows ones: UID and SID, root and Administrator,
sudoand Administrators - Create users and groups in three ways: Settings,
lusrmgr.mscand the command line - Explain UAC: why an administrator's programs start without administrator rights
- Disable, enable and delete accounts, and check every change with a command
- The trap: why a command can answer
Access is deniedto an administrator
The same ideas, other names¶
On Linux the truth about users lives in text files, and tools edit them. On Windows the truth lives in a database, and you only ever see it through a tool. Different house, same furniture:
| Idea | Linux | Windows |
|---|---|---|
| The user's real identity | UID, e.g. 1001 |
SID (security identifier), e.g. S-1-5-21-…-1002 |
| The all-powerful account | root, UID 0 |
The built-in Administrator, SID ending in -500; Windows setup leaves it disabled |
| The group with power | sudo |
Administrators |
| Normal people | Any user from UID 1000 | Members of the group Users: a standard user |
| Where accounts are kept | /etc/passwd, /etc/shadow: text files |
The SAM database: not a text file, read only through tools |
| Borrowing power | sudo command |
A UAC prompt ("Run as administrator") |
| The home folder | /home/marta, created with the user |
C:\Users\marta, created at her first sign-in |
A SID (security identifier) is the number Windows really uses to identify an account. The name is only a label for humans.
Careful: Administrator is not your account
The built-in Administrator is a separate account, disabled during setup. The account you created when installing Windows is a member of the group Administrators. One letter apart, two different things.
Two kinds of account¶
- A local account exists only inside this PC, like the Linux users you created in
deb-lab. - A Microsoft account is an online identity (an e-mail address) that Windows can use to sign in. Windows 11 pushes it hard during installation.
In this unit you use local accounts only. Company PCs use a third kind, domain accounts, which you will meet in Unit 6.
Three toolboxes¶
The same job can be done in three places. Not every edition of Windows has all of them:
| Tool | Windows 11 Home | Pro / Education / Enterprise |
|---|---|---|
| Settings → Accounts → Other users | ||
lusrmgr.msc — the Local Users and Groups console |
||
net user, net localgroup (old, short) |
||
PowerShell: New-LocalUser, Add-LocalGroupMember... |
To know which edition you have, press Win+R and type winver.
Users and groups with the mouse¶
In your win11 VM, the Exercise sheet walks you through it. The key moments:
- Settings → Accounts → Other users → Add account. Windows offers a Microsoft account. Look for the small print: I don't have this person's sign-in information, then Add a user without a Microsoft account. Create
marta. She appears as Local account, a standard user. - Win+R →
lusrmgr.msc(not on Home). Users → New User… createsjoan. Groups → New Group… createsdevwith marta, anddesignwith joan. - Open marta → Properties → Member Of: she is in Users and dev.
- Open
C:\Usersin File Explorer. There is no foldermartayet. Windows builds the profile the first time she signs in.
The three security questions
When you create a local account in Settings, Windows forces you to answer three security questions ("What was your first pet's name?"). Keep this in mind for the next page: are questions like that good security?
UAC: an administrator who is not one¶
A little history¶
Windows XP (2001): the account created at installation was an administrator, and so was every program it started — the browser, the game, the attachment someone double-clicked. One wrong click and the malware owned the machine. It happened millions of times.
With Windows Vista (2007) Microsoft added User Account Control, or UAC. People hated its constant questions; Windows 7 made it quieter; it has been there ever since.
Two key rings¶
An access token is the list of identities and rights that a program carries with it.
Picture an administrator who arrives with two key rings. One has the everyday keys. The other has the master keys, and it stays in the pocket.
- When a member of Administrators signs in, Windows gives them two access tokens: a standard one and an administrator one.
- The desktop, and everything you start from it, gets the standard token. So an administrator's browser runs with a standard user's rights.
- When a program needs more, Windows asks first. That question is the elevation prompt. It appears on the secure desktop: the screen goes dim and only Windows itself can click there, so no program can press "Yes" for you.
flowchart LR
SIGN["<b>Sign-in</b><br>member of Administrators"] --> STD["<b>Standard token</b><br>the everyday key ring"]
SIGN --> ADM["<b>Administrator token</b><br>the master keys, kept in the pocket"]
STD -->|"every program starts here"| APP["Browser, Terminal, games"]
APP -->|"needs more rights"| UAC["<b>UAC prompt</b><br>on the secure desktop"]
UAC -->|"Yes"| ADM
There are two kinds of prompt, and which one you see depends on who you are:
| You are in Administrators | You are a standard user | |
|---|---|---|
| Prompt | Consent prompt: Yes / No | Credential prompt: an administrator's name and password |
| Linux cousin | sudo (your own approval) |
su (someone else's password) |
A small shield icon on a button or a menu entry means "this will ask for elevation".
Careful: “I am an administrator, so everything I run is administrator”
No. Your programs start with the standard token. That is why a command can answer Access is denied to an administrator — until you open the terminal with Run as administrator.
See it with your own eyes¶
Open Terminal the normal way and try to create a user:
Now ask Windows which groups you carry:
In the line BUILTIN\Administrators the attributes say Group used for deny only, and the last line says Medium Mandatory Level. You are in the group, but this window is not using it.
Right-click Start → Terminal (Admin). The screen dims and the consent prompt asks Yes / No. Run whoami /groups in the new window: Administrators is now an Enabled group, and the level is High Mandatory Level. That is the second key ring.
Sign in as marta and try the same: a standard user gets the credential prompt, asking for an administrator's password.
The recommended way to use Windows, in Microsoft's own documentation, is to work every day as a standard user and type an administrator's password only when needed. It is the same rule you learnt on Linux: be student, borrow root for one command.
The same job with commands¶
Twelve employees are fine with the mouse. Twelve hundred are not. Every row below does the same job with the old net command (it works in CMD and PowerShell) and with the PowerShell cmdlets. Run them in Terminal (Admin):
| Job | net |
PowerShell |
|---|---|---|
| List users | net user |
Get-LocalUser |
| New user | net user aina * /add |
New-LocalUser -Name pau -Password $pw |
| New group | net localgroup admin /add |
New-LocalGroup -Name dev |
| Add to a group | net localgroup admin aina /add |
Add-LocalGroupMember -Group dev -Member pau |
| Who is in it | net localgroup admin |
Get-LocalGroupMember -Group dev |
| Disable | net user aina /active:no |
Disable-LocalUser -Name aina |
| Delete | net user temp /delete |
Remove-LocalUser -Name temp |
Two details matter:
- The
*innet user aina * /addmakes Windows ask for the password without showing it. Writing the password inside the command would leave it in the history. - PowerShell does not accept a password as plain text. First read it as a secure string, then use it:
$pw = Read-Host -AsSecureString "Password"
New-LocalUser -Name pau -Password $pw -FullName "Pau (intern)"
Careful: a new PowerShell user belongs to no group
A user created with New-LocalUser is in no group at all, not even Users, so it does not appear on the sign-in screen. net user /add and the graphical tools add the user to Users by themselves. Fix it with:
Careful: admin is not Administrators
At Tramuntana Apps, admin is the administration department (Aina does the office and finance work). It has no power at all. The group with power is Administrators — the same trap as admin and sudo on Linux.
Reading the SIDs¶
- Administrator ends in
-500andEnabledisFalse. Guest ends in-501. - The users you created end in numbers above 1000 — like Linux UIDs.
- All of them start with the same
S-1-5-21-…: that part identifies this PC.
Disable or delete?¶
Aina goes on leave. You do not delete her; you disable her:
| Disabled | Deleted | |
|---|---|---|
| Can she sign in? | No | No |
| Account and files | Stay | The account is gone |
| SID | Kept, she comes back the same | Gone for good: a new "aina" is a different person to Windows |
PowerShell 7 and the LocalUser cmdlets
If you installed PowerShell 7, the LocalUser cmdlets may refuse to load there. Use Windows PowerShell 5.1, the default profile of Terminal.
Key takeaways¶
- Windows identifies accounts by their SID, like Linux uses the UID. Accounts live in the SAM database, not in text files.
- A local account lives only on this PC; a Microsoft account is an online identity. The built-in Administrator (
-500) is disabled; your account is a member of the group Administrators. - UAC gives an administrator two access tokens. Programs start with the standard one; elevation asks first: consent prompt for administrators, credential prompt for standard users.
- The same jobs can be done in Settings,
lusrmgr.msc(not on Home),net user/net localgroup, and PowerShell cmdlets likeNew-LocalUser. New-LocalUseradds the user to no group: add them to Users yourself. Disabling keeps the SID; deleting loses it for good.
Quick check¶
1. What does Windows use, like the UID on Linux, to really identify an account?
- The user name typed at sign-in
- The SID, a security identifier
- The password hash of the account
- The path of the home folder
Windows identifies every account by its SID (security identifier), such as S-1-5-21-…-1002. The name is only a label for humans, exactly like the name in front of a UID in /etc/passwd.
2. You are a member of Administrators. In a normal Terminal, net user x /add answers Access is denied. Why?
- The command is wrong and needs PowerShell 7
- Your account has been disabled by UAC
- Programs start with your standard token until you elevate
- Only the built-in Administrator account may create users
UAC gives administrators two access tokens. Everything started from the desktop gets the standard one. Open Terminal (Admin), accept the consent prompt, and the same command works.
3. A standard user starts a program that needs elevation. What does UAC show?
- A prompt asking for an administrator's name and password
- A Yes / No question that the user can simply accept
- Nothing: the program runs with full rights silently
- Nothing: the program is blocked with no way to run it
A standard user has no administrator token to switch to, so UAC shows the credential prompt: somebody with administrator rights must type their password. It is the Windows cousin of su. Administrators get the consent prompt instead.
4. Which of these tools is missing in Windows 11 Home?
- The
net usercommand - Settings → Accounts → Other users
- The
New-LocalUsercmdlet - The
lusrmgr.mscconsole
The Local Users and Groups console, lusrmgr.msc, only exists from Pro up. On Home you do the same work with Settings, net user / net localgroup or the PowerShell cmdlets.
5. You created laia with New-LocalUser. She does not appear on the sign-in screen. What is missing?
- A restart of the PC to refresh the list
- Adding her to the group Users
- Linking her to a Microsoft account
- Creating the folder
C:\Users\laiafirst
New-LocalUser creates an account that belongs to no group. Run Add-LocalGroupMember -Group Users -Member laia. The home folder is not needed: Windows creates it at her first sign-in.
6. Aina will be on leave for three months and will come back. What is the best thing to do with her account?
- Delete it and create it again when she returns
- Disable it with
Disable-LocalUser -Name aina - Remove her from the group Administrators
- Change her password and tell nobody
Disabling stops anyone from signing in but keeps the account, its files and its SID. Deleting would lose the SID for good: a new "aina" would be a stranger to Windows, with none of the old permissions.
7. You check a family PC at home with whoami /groups. Pick the two statements that are true.
- If Administrators says "Group used for deny only", this window runs with the standard token
- Using a standard account every day and elevating only when needed is the safer setup
- The group admin in the list gives the same power as Administrators
- If you are in Administrators, every program you start already has full rights
"Group used for deny only" means the group is in your token but not in use: this is the standard token. Microsoft recommends working as a standard user and elevating only when needed — least privilege. A group called admin has no special power, and UAC starts every program with the standard token.
Now you know who can sign in and who can become an administrator. Next: how the system protects the passwords themselves, and how to force good ones — account and password policies.