Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:ressources:astuces:macos [2014/08/04 12:03] (current)
Line 1: Line 1:
 +====== MacOS tips ======
 +
 +===== Networking =====
 +
 +==== Get IP address ====
 +<​code>​
 +$ sudo ipconfig getifaddr en1
 +</​code>​
 +
 +==== Change IP address ====
 +<​code>​
 +$ sudo ipconfig set en1 INFORM 172.21.15.249 255.255.255.248
 +</​code>​
 +
 +==== Change default gateway ====
 +<​code>​
 +$ sudo route delete default
 +$ sudo route add default 172.21.15.254
 +</​code>​
 +
 +===== Users =====
 +
 +==== Get user details ====
 +<​code>​
 +$ sudo dscl . -read /Users/bob
 +</​code>​
 +
 +==== Delete a user ====
 +<​code>​
 +$ sudo dscl . -delete /Users/bob
 +</​code>​
 +
 +==== Create a user ====
 +This one requires a script to wrap all the steps:
 +<​file>​
 +#!/bin/bash
 +target_user=$1
 +[ -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)
 +userid=$((maxid+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'"​
 +</​file>​
 +
 +<​code>​
 +$ sudo bash create_user.sh bob
 +created user bob with id 502 and password '​Uv6D91hj27Tam'​
 +</​code>​
  
en/ressources/astuces/macos.txt ยท Last modified: 2014/08/04 12:03 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0