username <-> UID

Rob den Boer rob.den.boer at
Fri Oct 10 08:30:00 GMT 1997


 > From: Luke Kenneth Casson Leighton <lkcl at>
 > To: samba at
 > Subject: programming question, for samba.
 >Message-ID: <Pine.BSF.3.91.971009152807.9779I-100000 at>

 > help, help.  does anyone know of a generic way to convert string   
into a uid (user id)?

Put this in a script and make it executable:

awk 'BEGIN{FS=":"} { if ($1 == name) print $3}' name=$1 /etc/passwd

Works on almost every Unix flavour...

Rob den Boer

More information about the samba mailing list