Thursday, September 27, 2007

Tip for the day: THE NEXT UID

Here is one way to find out the next available UID on a system.

It takes both the password and group files and finds the next available UID and displays it.

(No cats were harmed in the making of this script)

#!/bin/bash
awk -F":" '{ print $3 }' /etc/passwd > number_list
awk -F":" '{ print $3 }' /etc/group >> number_list
A=` sort -g number_list | tail -1`
A=`expr $A + 1`
echo "New Available UID is $A"

No comments: