The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Want a list of users on your box? 26 August 2000
Need more help on this topic? Click here
This article has 7 comments
Show me similar articles
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.


Need more help on this topic? Click here
This article has 7 comments
Show me similar articles