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

BEGIN { FS=":" }
{ print $1 "\t" $5 }

save this a extractnames.awk . Now execute awk and include this file:

$ awk -f extractnames.awk /etc/passwd

The same output can be produced also by cut command:

$ cut -d : -f1,5 /etc/passwd 


Go to top