User Tools

Site Tools


MacOS tips


Get IP address

$ sudo ipconfig getifaddr en1

Change IP address

$ sudo ipconfig set en1 INFORM

Change default gateway

$ sudo route delete default
$ sudo route add default


Get user details

$ sudo dscl . -read /Users/bob

Delete a user

$ sudo dscl . -delete /Users/bob

Create a user

This one requires a script to wrap all the steps:

[ -z $target_user ] && echo "missing target user as first arg" && exit 1

pass=$(openssl rand -base64 12)

maxid=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)

dscl . -create /Users/$target_user
dscl . -create /Users/$target_user UserShell /bin/bash
dscl . -create /Users/$target_user UniqueID "$userid"
dscl . -create /Users/$target_user PrimaryGroupID 80
dscl . -create /Users/$target_user NFSHomeDirectory /Users/$target_user
dscl . -passwd /Users/$target_user $pass
dscl . -append /Groups/admin GroupMembership $target_user

cp -R /System/Library/User\ Template/English.lproj /Users/$target_user
chown -R $target_user:staff /Users/$target_user

echo "created user $target_user with id $userid and password '$pass'"
$ sudo bash bob
created user bob with id 502 and password 'Uv6D91hj27Tam'
en/ressources/astuces/macos.txt · Last modified: 2024/04/17 10:19 by