Sorting Human Users from System Users

Every Linux system has a bunch of system accounts (root, uucp, daemon, etc.) in addition to regular users. They’re all lumped together in /etc/password. How do you list your human users separately from system accounts?

Take advantage of Linux’s user identification (UID) numbering scheme and awk’s ability to sort by fields or columns. This is for a Debian or Slackware system:

$ awk -F: ‘$3 > 999 { print $0}’ /etc/passwd

To show a subset use:

$ awk -F: ‘($3 >= 1000) &&($3 <=1005) { print $0}’ /etc/passwd

This is for a Red Hat or SuSE system:

$ awk -F: ‘$3 > 499 { print $0}’ /etc/passwd

To sort them alphabetically use:

$ awk -F: ‘$3 > 499 { print $0}’ /etc/passwd | sort