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 

Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Go to top