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 cloud server in no time flat

Simple setup. Full root access. Straightforward pricing.


DEPLOY SERVER




Leave a Reply