pkill -U UID or
pkill -u UID or username instead of UID. Sometimes
skill -u USERNAME may work, another tool is
killall -u USERNAME.
Skill was a linux-specific and is now outdated, and pkill is more portable (Linux, Solaris, BSD).
pkill allow both numberic and symbolic UIDs, effective and real http://man7.org/linux/man-pages/man1/pkill.1.html
pkill - ... signal processes based on name and other attributes
-u, --euid euid,...
Only match processes whose effective user ID is listed.
Either the numerical or symbolical value may be used.
-U, --uid uid,...
Only match processes whose real user ID is listed. Either the
numerical or symbolical value may be used.
Man page of skill says is it allowed only to use username, not user id: http://man7.org/linux/man-pages/man1/skill.1.html
skill, snice ... These tools are obsolete and unportable. The command syntax is poorly defined. Consider using the killall, pkill
-u, --user user
The next expression is a username.
killall is not marked as outdated in Linux, but it also will not work with numberic UID; only username: http://man7.org/linux/man-pages/man1/killall.1.html
killall - kill processes by name
Kill only processes the specified user owns. Command names
I think, any utility used to find process in Linux/Solaris style /proc (procfs) will use full list of processes (doing some readdir of
/proc). I think, they will iterate over
/proc digital subfolders and check every found process for match.
To get list of users, use
getpwent (it will get one user per call).
skill (procps & procps-ng) and killall (psmisc) tools both uses
getpwnam library call to parse argument of
-u option, and only username will be parsed.
pkill (procps & procps-ng) uses both atol and getpwnam to parse
-U argument and allow both numeric and textual user specifier.