find /path -user NAME -print. If the account has been deleted and the name no longer resolves, that command will not return an empty list — it refuses to run. Search by number instead (find /path -user 1004), or sweep for orphans with find /path -nouser. This page covers ownership by user; for the group side of the same question — -group, -nogroup, setgid inheritance, and why -exec chmod and -delete are dangerous here — see finding files owned by a group, which measures all of it.
The name is not stored on the file. The number is.
This one fact explains every surprise in this article. A directory entry records a numeric UID; the name you see is looked up when something prints it:
$ stat -f 'stored uid=%u printed name=%Su %N' /usr/bin/sed
stored uid=0 printed name=root /usr/bin/sed
$ ls -l /usr/bin/sed | awk '{print $3, $4}'
root wheel
$ ls -ln /usr/bin/sed | awk '{print $3, $4}'
0 0
So the three obvious spellings are one query, not three. Counting regular files directly under /usr/bin:
-user root -> 879 files
-user 0 -> 879 files
-uid 0 -> 879 files
You do not need -uid to search by number — BSD find(1) says of -user: “If uname is numeric and there is no such user name, then uname is treated as a user ID.” GNU says the same: “File is owned by user uname (numeric user ID allowed).” -uid earns its place on GNU for a different reason: there it is a numeric comparison, “File’s numeric user ID is less than, more than or exactly n”, so -uid +1000 selects every human account at once. That comparison form is quoted from GNU find(1) and was not run here; the equality form above was.
After the account is deleted, -user stops working
When employees leave an organization, their files may need to be reassigned or deleted, and a search by user name does not survive the account’s deletion:
$ find /usr/bin -maxdepth 1 -user hw_departed_user
find: -user: hw_departed_user: no such user
rc=1
$ find /usr/bin -maxdepth 1 -user 64123
rc=0 (no output)
Loud failure on the name, silent success on the number. That is the right way round — a typo cannot masquerade as “no files found” — but it means the order of operations matters: run the search before you delete the account, or write the UID down first. Once /etc/passwd loses the entry, all you have left is the number, and the only tool that finds the number without knowing it is -nouser: “No user corresponds to file’s numeric user ID” (GNU find(1)). The primary is accepted and runs clean here, and it found nothing, which is the correct answer on a healthy machine. Creating a genuine orphan needs root, so the positive case is unverified — I exercised the primary, not a hit.
The related hazard is UID reuse. Because the number is what is stored, a new account created with a recycled UID inherits ownership of every file the old one left behind, and ls -l will print the new person’s name over the old person’s data with no indication anything happened. Sweep with -nouser and reassign before the number gets handed out again. (That consequence is inference from the stored-uid behaviour measured above, not something I could reproduce without creating accounts.)
“Files owned by X” is not “files X could read”
Used as a security-audit tool, -user answers a narrower question than that framing implies. Ownership controls who can change the permissions; it says nothing about who can read the contents. A world-readable file owned by a departing user is readable by everyone whether you find it or not, and the files that person could read are mostly owned by someone else. Two other precision problems worth knowing before you trust a sweep:
# s/link is a symlink I own, pointing at /usr/bin/sed, which uid 0 owns
$ find s -user 0 -> 0 matches
$ find -L s -user 0 -> 1 match
find does not follow symlinks by default, so -user tests the link itself, not what it points at; -L flips that. And a sweep from / as a non-root user silently misses everything in directories you cannot read, while exiting non-zero — both measured on the group page. Add -xdev so you do not walk into network mounts, send stderr to a file rather than /dev/null, and read the list with -print before you attach any action to it. The script that reproduces the checks above uses only /usr/bin and its own scratch directory, and prints no account name.
Should this page and the group page be one? They overlap in syntax and not in failure mode: the interesting thing about groups is inheritance (a new file lands in the directory’s group, not yours), and the interesting thing about users is that accounts get deleted and their numbers get reused. Keeping them apart and cross-linking is honest; merging them would mean one page with two unrelated warnings.