Last active
January 4, 2017 15:21
-
-
Save n8felton/4f0ecf2e345286762831e6feb6ccbe5b to your computer and use it in GitHub Desktop.
macOS Command Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Retrieve the Serial Number | |
| ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}' | |
| # Retrieve the Hardware UUID | |
| ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformUUID/{print $(NF-1)}' | |
| # Retrieve the Model Identifier, e.g. iMac16,1; Macmini7,1' VMware7,1 | |
| sysctl -n hw.model | |
| # Convert macOS SMB path to UNC path | |
| echo "smb://myserver.example.com/sharename" | sed -e 's_smb://\(.*\)_\\\\\1_g' -e 's_\/_\\_g' | |
| # \\myserver.example.com\sharename | |
| # Convert UNC path to macOS SMB path | |
| echo "\\myserver.example.com\sharename" | sed -e 's_\(.*\)_smb:\\\1_g' -e 's_\\_\/_g' | |
| # smb://myserver.example.com/sharename | |
| # Retrieve the Darwin Cache or Temp dir variables | |
| getconf DARWIN_USER_CACHE_DIR | |
| getconf DARWIN_USER_TEMP_DIR | |
| # Root Defaults | |
| # Cache: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/ | |
| # Temp: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/ | |
| # User Example | |
| # Cache: /var/folders/wt/c230x4391yn3qmb9j2sb90v40000gn/C/ | |
| # Temp: /var/folders/wt/c230x4391yn3qmb9j2sb90v40000gn/T/ | |
| # Determine the home directory for all users on a machine | |
| USERS=$(dscl /Local/Default -list /Users uid | awk '($2>=500) && ($2<=10000) {print $1}') | |
| for USERNAME in $USERS; do | |
| USER_HOME=$(eval echo "~$USERNAME") | |
| echo $USER_HOME | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment