KB Knowledge Base
How To Extract A User List From Your Linux System

Article By kevin


Linux User

Here is a simple way to extract the User Name and full name for all the users on your Linux system. Both methods divide the /etc/passwd file into columns and print column 1 and 5 where ":" is used as a common delimiter. Column 1 contains the username and column 5 contains the full name. Using awk:

BEGIN { FS=":" }
{ print $1 "\t" $5 }
save this as extractnames.awk . Now execute awk and include this file:
$ awk -f extractnames.awk /etc/passwd
The same output can be produced by cut command:
$ cut -d : -f1,5 /etc/passwd 

Tags: , , , ,

Spin up a VPS server in no time flat

Simple setup. Full root access. Straightforward pricing.


Leave a Reply