- system information
- System Integrity Protection
- change Mac default settings
- development environment
- Homebrew
- system settings
- accessory
- q&a
[!TIP|label:reference]
- osx chflags man page
- Show Hidden Files in Mac OS X
- Mac Keyboard Shortcuts
- How to reinstall macOS
- How to Find the Wi-Fi Password of your Current Network
- How to Find Wi-Fi Network Passwords from Command Line on Mac
- 5 Stupid Terminal Tricks to Keep You Entertained
- Install Nokogiri
- OSX实用命令
- Locking files and folders to prevent changes
system information
get osx info
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G73
# or
$ sw_vers --productName
macOS
$ sw_vers --productVersion
14.4.1
$ /usr/sbin/system_profiler SPHardwareDataType
Hardware:
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro15,1
Processor Name: 6-Core Intel Core i7
Processor Speed: 2.2 GHz
Number of Processors: 1
Total Number of Cores: 6
L2 Cache (per Core): 256 KB
L3 Cache: 9 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB
Boot ROM Version: 1037.147.1.0.0 (iBridge: 17.16.16065.0.0,0)
Serial Number (system): C02XFGWEJG5H
Hardware UUID: 4EA008BF-9B36-5F1D-9151-AD4F64808AAB
Activation Lock Status: Enabled
get CPU information
$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
# or
$ sysctl machdep.cpu
machdep.cpu.max_basic: 22
machdep.cpu.max_ext: 2147483656
machdep.cpu.vendor: GenuineIntel
machdep.cpu.brand_string: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
machdep.cpu.family: 6
...
get more details
$ sysctl -a
reboot if system freezes
$ sudo systemsetup -setrestartfreeze on
setup hostname and localhostname
$ sudo scutil --set HostName [HOSTNAME]
$ sudo scutil --set LocalHostName [HOSTNAME]
$ sudo scutil --set ComputerName [HOSTNAME] # Optional
$ dscacheutil -flushcache # Flush the DNS Cache
$ sudo shutdown -r now
setup bash as default SHELL
$ chsh -s /bin/bash
# OR
$ chsh -s `which bash`
disable guest user
$ dscl . delete /Users/Guest
$ sudo defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO
$ sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO
go to hidden path in finder
Command+Shift+G
reindex spotlight
$ sudo mdutil -i on /
$ sudo mdutil -E /
$ sudo mdutil -E /Volumes/marslo/
- or
$ sudo mdutil -i off / $ sudo rm -rf /.Spotlight-V100 $ sudo rm -rf /.Spotlight-V200 $ sudo mdutil -i on / $ sudo mdutil -E / $ sudo mdutil -E /Volumes/marslo/
copy STDOUT into clipboard
refer to: osx/tricky
Copy path from finder
refer to: osx/tricky
System Integrity Protection
refer to: osx/tricky
change Mac default settings
refer to: osx/defaults
development environment
setup JAVA_HOME
$ /usr/libexec/java_home -v 1.8.0.162 -exec javac -versioin
xCode
refer to osx
xCode installation
- Install from App Store
- Offline Package
- more details
xCode setup
$ sudo xcodebuild -license [accept]
xCode commandline tools
verify installed or not
$ xcode-select -p
xCode commandline tools installation
$ xcode-select --install xcode-select: note: install requested for command line developer tools
upgrade commandline tools
$ softwareupdate --all --install --force
- or
$ sudo rm -rf /Library/Developer/CommandLineTools $ sudo xcode-select --install
- or
list history
`bash $ softwareupdate --history
xcode components installation
$ for pkg in /Applications/Xcode.app/Contents/Resources/Packages/*.pkg; do
> sudo installer -pkg "$pkg" -target /;
> done
example:
$ ls -altrh /Applications/Xcode.app/Contents/Resources/Packages/ total 180512 -rw-r--r-- 1 root wheel 87K Mar 10 2017 MobileDeviceDevelopment.pkg -rw-r--r-- 1 root wheel 5.4M Sep 30 05:28 XcodeSystemResources.pkg -rw-r--r-- 1 root wheel 11K Sep 30 05:28 XcodeExtensionSupport.pkg -rw-r--r-- 1 root wheel 83M Sep 30 05:28 MobileDevice.pkg drwxr-xr-x 6 root wheel 204B Oct 11 05:23 ./ drwxr-xr-x 87 root wheel 2.9K Oct 11 05:55 ../ $ for pkg in /Applications/Xcode.app/Contents/Resources/Packages/*.pkg; do -> sudo installer -pkg "$pkg" -target /; -> done installer: Package name is MobileDevice installer: Upgrading at base path / installer: The upgrade was successful. installer: Package name is MobileDeviceDevelopment installer: Installing at base path / installer: The install was successful. installer: Package name is XcodeExtensionSupport installer: Installing at base path / installer: The install was successful. installer: Package name is XcodeSystemResources installer: Installing at base path / installer: The install was successful.
enable developer mode
$ DevToolsSecurity -enable
show sdk path
[!NOTE|label:more:]
$ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Homebrew
refer to: osx/apps.md
system settings
refer to: osx/apps
accessory
refer to: osx/apps
q&a
x86_64 liblzma.dylib in nokogiri
solution 1:
$ brew unlink xz $ gem install nokogiri # or gem install cupertino $ brew link xz
solutioin 2 (using system libraies):
$ brew install libxml2 $ gem install nokogiri -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2 # or $ bundle config build.nokogiri --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2 $ bundle install # or $ brew link --force libxml2 $ gem install nokogiri -v '1.7.0.1' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib