Add user that can not be seen

pedz

Registered
I didn't know how to title this question.

I have fast user switching enabled. I want to add a user that can do everything but I do not want to see it listed in the fast user switch menu. If this implies that the user can not log in directly, thats ok. This is for my postgres user. I want to be able to su to postgres.

I'm assuming that I will need to use dscl but was hoping for a script or some suggestions of how to do it.

Thank you
 
I am not sure exactly what causes the user to be hidden but this script creates a postgres user that does not show up in the list of users you can fast switch between nor the list of users shown by System Preferences => Accounts.

Enjoy,
Code:
#!/bin/bash

# We loop to find a numeric value which is not a users uniqueid or a groups
# primary group id starting at 501
typeset -i uid=501
while [[ "$( dscl . search Users UniqueID $uid && 
             dscl . search Groups PrimaryGroupID$uid )" ]] ; do
    let ++uid
done

dscl . create /Users/postgres
dscl . create /Users/postgres UniqueID $uid
dscl . create /Users/postgres PrimaryGroupID $uid
dscl . create /Users/postgres NFSHomeDirectory /Users/postgres
dscl . create /Users/postgres Password '*'
dscl . create /Users/postgres UserShell /bin/bash
dscl . create /Users/postgres RealName 'Postgres Admin User'

dscl . create /Groups/postgres
dscl . create /Groups/postgres PrimaryGroupID $uid
dscl . create /Groups/postgres RealName 'Postgres Admin Group'

if [[ ! -d /Users/postgres ]] ; then
    mkdir /Users/postgres
fi
chown -R postgres:postgres /Users/postgres
 
Back
Top