Want a list of users on your box?

If you ever want a list of users on your system, use this little script:

cat /etc/passwd | cut -d: -f1 | grep -v \#

The cut command selects portions of a file. We use ":" as
the delimiting character. And we want only the first field. The grep
eliminates lines with # in them, which normally appear at the start of the password file.

Exercises for the interested and motivated:

try the above command without the grep

remove the \ before the #

try -f5 instead of -f1.

Hope that helps.

My thanks to halflife for the original idea and to pal for adding the grep.