book
  • README
  • cheatsheet
    • bash
      • builtin
      • syntactic sugar
      • cmd
      • havefun
    • text-processing
      • awk
      • sed
      • html
      • json
      • regex
      • unicode
    • osx
    • curl
    • tricky
    • widget
    • proxy
    • colors
    • math
    • media
    • ssl
      • keystore
      • verification
      • server
      • client
      • tricky
    • windows
      • powershell
      • choco
      • wsl
      • wt
      • shortcut
      • clsid
      • env
      • shell:folder
  • vim
    • nvim
    • install
    • color
    • plugins
      • usage
      • other plugins
      • deprecated
    • tricky
    • viml
    • windows
    • troubleshooting
  • devops
    • admin tools
    • ssh
    • git
      • config
      • alias
      • submodule
      • eol
      • example
      • gerrit
        • gerrit API
      • github
      • troubleshooting
      • tricky
      • statistics
    • pre-commit
    • release-tools
    • tmux
      • cheatsheet
    • ansible
    • vault
    • artifactory
      • api
      • cli
      • aql
      • nginx cert
    • klocwork
      • kwadmin
      • kwserver
      • api
      • q&a
    • elk
    • mongodb
    • android
    • mobile
  • jenkins
    • config
      • windows
    • appearance
    • troubleshooting
    • jenkinsfile
      • utility
      • parallel
      • build
      • envvar
      • properties
      • trigger
      • node
    • script
      • job
      • build
      • stage
      • agent
      • security & authorization
      • exception
      • monitor
      • tricky
    • api
      • blueocean
    • cli
    • plugins
      • kubernetes
      • docker
      • shared-libs
      • lockable-resource
      • ansicolor
      • badge
      • groovy-postbuild
      • simple-theme
      • customizable-header
      • artifactory
      • jira-steps
      • job-dsl
      • build-timeline
      • crumbIssuer
      • coverage
      • uno-choice
      • tricky
  • virtualization
    • kubernetes
      • init
        • kubespray
        • kubeadm
          • environment
          • crio v1.30.4
          • docker v1.15.3
          • HA
        • addons
        • etcd
      • kubectl
        • pod
        • deploy
        • replicasets
        • namespace
        • secrets
      • node
      • certificates
      • events
      • kubeconfig
      • kubelet
      • troubleshooting
      • cheatsheet
      • auth
      • api
      • tools
        • monitor
        • helm
        • network
        • minikube
    • docker
      • run & exec
      • voume
      • remove
      • show info
      • dockerfile
      • dockerd
      • tricky
      • troubleshooting
      • windows
    • crio
    • podman
  • ai
    • prompt
  • osx
    • apps
      • init
      • brew
    • defaults
    • system
    • network
    • script
    • tricky
  • linux
    • devenv
    • util
      • time & date
      • output formatting
      • params
      • tricky
    • nutshell
    • disk
    • network
    • troubleshooting
    • system
      • apt/yum/snap
      • authorization
      • apps
      • x11
    • ubuntu
      • systemctl
      • x
    • rpi
  • programming
    • groovy
    • python
      • config
      • basic
      • list
      • pip
      • q&a
    • others
    • archive
      • angular
      • maven
      • mysql
        • installation
        • logs
      • ruby
        • rubyInstallationQ&A
  • tools
    • fonts
    • html & css
    • Jira & Confluence
    • node & npm
      • gitbook
      • hexo
      • github.page
      • code themes
    • app
      • microsoft office
      • vscode
      • virtualbox
      • iterm2
      • browser
      • skype
      • teamviewer
      • others
  • quotes
  • english
Powered by GitBook
On this page
  • system information
  • System Integrity Protection
  • change Mac default settings
  • development environment
  • Homebrew
  • system settings
  • accessory
  • q&a
  • tips

Was this helpful?

  1. cheatsheet

osx

PreviousunicodeNextcurl

Last updated 3 months ago

Was this helpful?

[!TIP|label:reference]

system information

[!NOTE|label:references:]

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/
  • $ 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

Copy path from finder

change Mac default settings

development environment

$ /usr/libexec/java_home -v 1.8.0.162 -exec javac -versioin

xCode

xCode installation

  • Install from App Store

  • Offline Package

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
  • list history

    $ 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

system settings

accessory

q&a

  • 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

tips

system tool upgrade

cmd

$ /usr/sbin/softwareupdate --all --install --force

# list history
$ /usr/sbin/softwareupdate --history
  • settings

    $ tail /private/var/log/install.log
    ...
    2024-12-13 00:55:45-08 HNWH3C04CX softwareupdated[572]: SUOSUMobileSoftwareUpdateController: Updating additionalUpdateMetricEventFields: {
          autoUpdate = false;
          buddy = false;
          commandLine = true;
          installTonight = false;
          mdm = false;
          notification = false;
          settings = false;
      }
    ...
  • install/uninstall package

    • *.pkg

      $ sudo installer -pkg /path/to/package.pkg -target /
      $ sudo installer -pkg /path/to/package.pkg -target / -uninstall

process

  • trustd

    $ ps aux | grep trustd
    marslo             836  10.7  0.1 410449040  22240   ??  S    Thu12PM  11:20.83 /usr/libexec/trustd --agent
    _trustd            414   5.4  0.1 410447680  23744   ??  Ss   Thu12PM  22:51.11 /usr/libexec/trustd
    _spotlight        1768   0.0  0.0 410389120  14144   ??  S    Thu12PM   0:07.70 /usr/libexec/trustd --agent
    _accessoryupdater   677   0.0  0.0 410380144   5728   ??  S    Thu12PM   0:00.93 /usr/libexec/trustd --agent
    _cmiodalassistants   615   0.0  0.0 410380128   5840   ??  S    Thu12PM   0:00.88 /usr/libexec/trustd --agent
    _locationd         570   0.0  0.0 410380144   5872   ??  S    Thu12PM   0:00.87 /usr/libexec/trustd --agent
    marslo           20127   0.0  0.0 410593776   1232 s001  S+   11:31AM   0:00.00 grep -i --color=always trustd
    root               423   0.0  0.0 410346128   3744   ??  Ss   Thu12PM   0:00.04 /usr/libexec/trustdFileHelper
  • accountd

    $ ps aux | grep account
    marslo           34564   0.0  0.0 411096384  12752   ??  Ss   Thu09PM   0:00.12 /System/Library/PrivateFrameworks/RemoteManagement.framework/XPCServices/AccountSubscriber.xpc/Contents/MacOS/AccountSubscriber
    marslo            2037   0.0  0.0 410400912  18096   ??  S    Thu12PM   0:00.61 /usr/libexec/appleaccountd
    _rmd              2032   0.0  0.0 410902768   9696   ??  Ss   Thu12PM   0:00.06 /System/Library/PrivateFrameworks/RemoteManagement.framework/XPCServices/AccountSubscriber.xpc/Contents/MacOS/AccountSubscriber
    root              1442   0.0  0.0 410993328  14272   ??  Ss   Thu12PM   0:08.17 /private/var/db/com.apple.xpc.roleaccountd.staging/exec/16777229.34120.xpc/Contents/MacOS/com.apple.NRD.UpdateBrainService
    root              1443   0.0  0.0 410378000   4240   ??  Ss   Thu12PM   0:00.06 /usr/libexec/xpcroleaccountd -launchd
    marslo             977   0.0  0.1 410442688  19280   ??  S    Thu12PM   0:14.47 /System/Library/PrivateFrameworks/AppleMediaServices.framework/Resources/amsaccountsd
    marslo             817   0.0  0.2 410643792  82720   ??  S    Thu12PM   1:41.97 /System/Library/Frameworks/Accounts.framework/Versions/A/Support/accountsd
    root               601   0.0  0.0 410400864   3984   ??  Ss   Thu12PM   0:00.05 /System/Library/PrivateFrameworks/AccountPolicy.framework/XPCServices/com.apple.AccountPolicyHelper.xpc/Contents/MacOS/com.apple.AccountPolicyHelper
    marslo           13632   0.0  0.0 410433248  12704   ??  S    11:14AM   0:00.11 /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Resources/storeaccountd
  • installd

    $ ps aux | grep installd
    root              1165  92.5  1.8 411273744 668928   ??  Rs   Thu12PM   8:45.34 /System/Library/PrivateFrameworks/PackageKit.framework/Resources/installd
    root              1166   0.0  0.0 410387200  10016   ??  Ss   Thu12PM   0:02.80 /System/Library/PrivateFrameworks/PackageKit.framework/Resources/system_installd
    root               584   0.0  0.0 410360448   6624   ??  Ss   Thu12PM   0:00.04 /usr/libexec/bootinstalld
    root               413   0.0  0.0 411112672   3920   ??  Ss   Thu12PM   0:00.19 /usr/libexec/containermanagerd_system --runmode=privileged --user-container-mode=current --bundle-container-mode=global --bundle-container-owner=_appinstalld --system-container-mode=none
    root               311   0.0  0.0 410189360   4384   ??  Ss   Thu12PM   0:14.45 /System/Library/PrivateFrameworks/Uninstall.framework/Resources/uninstalld

GUI

  • Software Update

    $ open "/System/Library/CoreServices/Software Update.app"
    $ open "/System/Library/CoreServices/Software Update.app/Contents/Resources/softwareupdated"
  • SoftwareUpdateNotificationManager

    $ open /System/Library/PrivateFrameworks/SoftwareUpdate.framework/Versions/A/Resources/SoftwareUpdateNotificationManager.app
    $ open /System/Library/PrivateFrameworks/SoftwareUpdate.framework/Versions/A/Resources/SoftwareUpdateNotificationManager.app/Contents/MacOS/SoftwareUpdateNotificationManager
  • patch

    • 14.7.2: https://swscan.apple.com/content/catalogs/others/index-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz

refer to:

refer to:

refer to:

refer to:

refer to

refer to:

refer to:

refer to:

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
* iMarslo: osx system
system_profiler -usage
tips and tricks
or
osx/tricky
osx/tricky
System Integrity Protection
osx/tricky
osx/defaults
setup JAVA_HOME
osx
xCode 9.0.1
Command_Line_Tools_macOS_10.13_for_Xcode_9.0.1
All Packages
more details
* iMarslo: osx/apps
osx/apps.html
osx/apps
osx/apps
x86_64 liblzma.dylib in nokogiri
system information
get osx info
reboot if system freezes
setup hostname and localhostname
setup bash as default SHELL
disable guest user
go to hidden path in finder
reindex spotlight
copy STDOUT into clipboard
Copy path from finder
System Integrity Protection
change Mac default settings
development environment
setup JAVA_HOME
xCode
Homebrew
system settings
accessory
q&a
x86_64 liblzma.dylib in nokogiri
tips
system tool upgrade
system-info