Sponsored Content
Operating Systems OS X (Apple) Hidding The Administrator Account in OS X 10.5 (Leopard) Post 302189006 by tlarkin on Thursday 24th of April 2008 04:37:39 PM
Old 04-24-2008
I have a script that creates this now, the script is still with in testing phases so it may or may not work 100% please use at your own risk, and if you make any tweaks let me know to make it better.

Code:
#!/bin/bash

if [ -z $1 ] ; then
	echo "usage: `basename $0` [username] [password] ([UID] optional) ([GID] optional)"
	exit 1
fi

USERNAME=$1
PASSWORD=$2
USERID=$3
GROUPID=$4

if [ `uname -r | cut -c1` = 8 ] ; then
	PATH='/NetInfo/root'
elif [ `uname -r | cut -c1` = 9 ] ; then
	PATH='/Local/Default'
else
	exit 1
fi

if [ -z $GROUPID ] || [ -z $UNIQUEID ] ; then
	GROUPID=0
	UNIQUEID=489
fi

checkUser ()
{
	if [[ `/usr/bin/dscl localhost list /Local/Default/Users | /usr/bin/grep "$USERNAME" | /usr/bin/grep -v "$USERNAME." | /usr/bin/grep -v ".$USERNAME"` == "$USERNAME" ]] ; then
		echo "the username '$USERNAME' already exists"
		exit 1
	fi
}

makeUser ()
{
	/usr/bin/sudo /usr/bin/dscl localhost create $PATH/Users/$USERNAME
	/usr/bin/sudo /usr/bin/dscl localhost create $PATH/Users/$USERNAME PrimaryGroupID 0
	/usr/bin/sudo /usr/bin/dscl localhost create $PATH/Users/$USERNAME UniqueID 0
	/usr/bin/sudo /usr/bin/dscl localhost create $PATH/Users/$USERNAME UserShell /bin/bash
	/usr/bin/sudo /usr/bin/dscl localhost passwd $PATH/Users/$USERNAME $PASSWORD
	/usr/bin/sudo /usr/bin/dscl localhost append $PATH/Groups/admin GroupMembership $USERNAME
}

moveUser ()
{
    /bin/echo "creating new admin account homedir..."
	/bin/mkdir -p /var/home/$USERNAME
	/usr/bin/ditto -rsrc -V /System/Library/User\ Template/English.lproj/ /var/home/$USERNAME/
	/usr/sbin/chown -Rf $USERNAME:admin /var/home/$USERNAME
	/bin/echo "confirming what we just did..."
	/bin/ls /var/home/$USERNAME/
	/usr/bin/id $USERNAME
	/bin/echo "if that looks good, we're all set."
}	

deleteUser ()
{
	/usr/bin/sudo /usr/bin/dscl localhost delete $PATH/Users/$USERNAME
	/usr/bin/sudo /usr/bin/dscl localhost delete $PATH/Groups/admin GroupMembership $USERNAME
}

hideUser ()
{
	/usr/bin/sudo /bin/cp -n /Library/Preferences/com.apple.loginwindow.plist /Library/Preferences/com.apple.loginwindow.plist.backup
	/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow Hide500Users -bool TRUE
	/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array $USERNAME
	/usr/bin/sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow SHOWOTHERUSERS_MANAGED -bool FALSE
}

checkUser
makeUser
moveUser
hideUser
#deleteUser

You will need to fill in the blanks, and it also moves the hidden account's home directory to /private/var/home
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Hidding Files in UNIX

:o ! HELLO SIR, 1) In UNIX how to hide & unhide a file. What are the Commands are there . ----------- :confused: 2) One more thing is that when i using WILD CARDS .The commands are not working Properly. Why like that. Please help me . (3 Replies)
Discussion started by: smdakram
3 Replies

2. UNIX for Dummies Questions & Answers

Setting an account to be a non-login account automatically?

Is there a way to easily change an account to be a non login account (NP in the shadow) file? I know I can just edit the file but that is not what we want to do. We use access control software and want to provide a way to set an account to be non-login using simple commands that can be mapped... (0 Replies)
Discussion started by: LordJezo
0 Replies

3. UNIX for Dummies Questions & Answers

Change Account to not lock account if password expires

I have access to 15+ UNIX boxes at work, and I do not consistently log onto all of them over time. When I do try to access one I havent been on in awhile, my account is locked as the password has expired. I need to request to the UNIX SA's that the password expiration is 90 days and that if it... (1 Reply)
Discussion started by: stringzz
1 Replies

4. What is on Your Mind?

Unix Administrator and Linux Administrator transition

Hello Unix Experts, I'm going to be graduating with a CIS (Computer Information Systems) degree in the coming year. I have been offered an internship with a job title of Unix Administrator under a well known company. I understand that Unix is used for high-end servers in many large... (1 Reply)
Discussion started by: brentmd24
1 Replies

5. Linux

Apply disk quota to account(dedicate 3 GB to account).

Hi , I am faceing lot of problem due to "disk space is not enough". senerio is like as, In system has 5 account. a,b,c,d,e say account c if very critical. Due to other user's data, user 'c' is faceing disk space issue. I want to dedicate 3 GB for user 'c'. No user... (1 Reply)
Discussion started by: ashokd009
1 Replies

6. Forum Support Area for Unregistered Users & Account Problems

Restart old account, change email for account

Hi there, I may have had a typo in my email previously provided. I have doublechecked my email for Scott's reply but havent seen it, so I am creating a new post. My new email can be either one of these: <removed> or <removed> I beleive my old email was <removed by admin> thanks for your... (1 Reply)
Discussion started by: AKelam_MagnusA
1 Replies

7. How to Post in the The UNIX and Linux Forums

Simultaneously try to execute commands after connecting to remote account to one account

I have made password less connection to my remote account. and i tried to execute commands at a time. but i am unable to execute the commands. ssh $ACCOUNT_DETAILS@$HOST_DETAILS cd ~/JEE/*/logs/ (1 Reply)
Discussion started by: kishored005
1 Replies

8. Windows & DOS: Issues & Discussions

What happens to your skype account if you close outlook.com email account?

Hello, Does anyone know what happens to your skype account if you close the outlook.com email account which are linked together? As you know they are both owned by Microsoft. Thanks (0 Replies)
Discussion started by: milhan
0 Replies

9. UNIX for Beginners Questions & Answers

Create a shell script to gather user account information and displays the result to administrator

I want to create a shell script to gather user account information and displays the result to administrator. I have created a script but its showing all the information when i search for username like: amit@mx:~$ ./uinfo.sh amit Username : amit User Info ... (2 Replies)
Discussion started by: amit1986
2 Replies
GZEXE(1)                                                      General Commands Manual                                                     GZEXE(1)

NAME
gzexe - compress executable files in place SYNOPSIS
gzexe name ... DESCRIPTION
The gzexe utility allows you to compress executables in place and have them automatically uncompress and execute when you run them (at a penalty in performance). For example if you execute ``gzexe /usr/bin/gdb'' it will create the following two files: -rwxr-xr-x 1 root root 1026675 Jun 7 13:53 /usr/bin/gdb -rwxr-xr-x 1 root root 2304524 May 30 13:02 /usr/bin/gdb~ /usr/bin/gdb~ is the original file and /usr/bin/gdb is the self-uncompressing executable file. You can remove /usr/bin/gdb~ once you are sure that /usr/bin/gdb works properly. This utility is most useful on systems with very small disks. OPTIONS
-d Decompress the given executables instead of compressing them. SEE ALSO
gzip(1), znew(1), zmore(1), zcmp(1), zforce(1) CAVEATS
The compressed executable is a shell script. This may create some security holes. In particular, the compressed executable relies on the PATH environment variable to find gzip and some standard utilities (basename, chmod, ln, mkdir, mktemp, rm, sleep, and tail). BUGS
gzexe attempts to retain the original file attributes on the compressed executable, but you may have to fix them manually in some cases, using chmod or chown. GZEXE(1)
All times are GMT -4. The time now is 03:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy