system tools

hostinfo

$ hostinfo
Mach kernel version:
   Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
Kernel configured for up to 12 processors.
6 processors are physically available.
12 processors are logically available.
Processor type: x86_64h (Intel x86-64h Haswell)
Processors active: 0 1 2 3 4 5 6 7 8 9 10 11
Primary memory available: 16.00 gigabytes
Default processor set: 463 tasks, 2557 threads, 12 processors
Load average: 2.72, Mach factor: 9.26

get human-readable vm_stat

$ paste <(vm_stat | awk 'NR>1' | grep -o ".*:") <(for i in $(vm_stat | awk 'NR>1' | tr -d '.' | awk '{print $NF}'); do perl -e "print $i/1024" | awk '{printf "%0.2f", $0}'; echo; done) | column -s: -t
Pages free                      328.70
Pages active                    910.00
Pages inactive                  973.38
Pages speculative               39.51
Pages throttled                 0.00
Pages wired down                852.52
Pages purgeable                 389.65
"Translation faults"            174323.38
Pages copy-on-write             7828.62
Pages zero filled               127404.04
Pages reactivated               3420.56
Pages purged                    6392.20
File-backed pages               656.69
Anonymous pages                 1266.20
Pages stored in compressor      2536.76
Pages occupied by compressor    991.23
Decompressions                  1555.85
Compressions                    8494.54
Pageins                         7799.75
Pageouts                        11.98
Swapins                         43.15
Swapouts                        48.46

show system info

$ glances

show memory

$ top -o MEM

iStat

 $ istats
--- CPU Stats ---
CPU temp:               53.19°C     ▁▂▃▅▆▇

--- Fan Stats ---
Total fans in system:   2
Fan 0 speed:            2157 RPM    ▁▂▃▅▆▇
Fan 1 speed:            1995 RPM    ▁▂▃▅▆▇

--- Battery Stats ---
Battery health:         unknown
Cycle count:            34          ▁▂▃▅▆▇  3.4%
Max cycles:             1000
Current charge:         6093 mAh    ▁▂▃▅▆▇  100%
Maximum charge:         6237 mAh    ▁▂▃▅▆▇  85.0%
Design capacity:        7336 mAh
Battery temp:           36.5°C

For more stats run `istats extra` and follow the instructions.

show Mach virtual memory statistics

$ vm_stat

check process without interactive mode

$ top -l 1 -n 0

example

$ top -l 1 -n 0
Processes: 472 total, 3 running, 469 sleeping, 2589 threads
2020/11/02 16:10:28
Load Avg: 2.67, 2.88, 3.12
CPU usage: 33.4% user, 20.46% sys, 46.49% idle
SharedLibs: 268M resident, 69M data, 44M linkedit.
MemRegions: 112888 total, 3016M resident, 90M private, 2802M shared.
PhysMem: 16G used (3742M wired), 420M unused.
VM: 3201G vsize, 1993M framework vsize, 44188(0) swapins, 49627(0) swapouts.
Networks: packets: 1575080/1561M in, 1302980/954M out.
Disks: 1368885/28G read, 648911/13G written.
  • or
    $ top -l 1 -s 0
    

show system

Serial Number

$ /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: 10**.***.*.*.* (iBridge: 17.**.*****.*.*,*)
      Serial Number (system): ************
      Hardware UUID: ********-****-****-****-************
      Activation Lock Status: Enabled

hardware

  • cpu manufacture
    $ 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
    ...
    

memory

$ system_profiler SPHardwareDataType | grep  "Memory:\|Cores:\|Processors:"
      Number of Processors: 1
      Total Number of Cores: 6
      Memory: 16 GB
  • or

    $ sysctl hw.memsize
    hw.memsize: 17179869184
    
    $ sysctl hw.ncpu
    hw.ncpu: 12
    

memory slot

$ system_profiler SPMemoryDataType
Memory:

    Memory Slots:

      ECC: Disabled
      Upgradeable Memory: No

        BANK 0/ChannelA-DIMM0:

          Size: 8 GB
          Type: DDR4
          Speed: 2400 MHz
          Status: OK
          Manufacturer: Micron
          Part Number: **********-*****
          Serial Number: -

        BANK 2/ChannelB-DIMM0:

          Size: 8 GB
          Type: DDR4
          Speed: 2400 MHz
          Status: OK
          Manufacturer: Micron
          Part Number: **********-*****
          Serial Number:

swap usage

$ sysctl vm.swapusage
vm.swapusage: total = 1024.00M  used = 34.00M  free = 990.00M  (encrypted)

show kernel version

$ sysctl kern.version
kern.version: Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64

$ sysctl kern.ostype
kern.ostype: Darwin

$ sysctl kern.osrelease
kern.osrelease: 20.1.0

$ sysctl kern.osrevision
kern.osrevision: 199506
  • or
    $ uname -a
    Darwin iMarslo 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin
    

list printer status

$ lpstat -a
printer-01 accepting requests since Wed Feb  3 16:40:50 2021

osx installation

download older version

$ softwareupdate --fetch-full-installer
  • or

    $ softwareupdate --fetch-full-installer --full-installer-version **.**.*
    
    # i.e.:
    $ softwareupdate --fetch-full-installer --full-installer-version 10.15
    
  • MacOS Mojave 10.14.6 Installer

    $ softwareupdate --fetch-full-installer --full-installer-version 10.14.6
    
  • MacOS Catalina 10.15.3 Installer
    $ softwareupdate --fetch-full-installer --full-installer-version 10.15.3
    
  • MacOS High Sierra 10.13.6 Installer
    $ softwareupdate --fetch-full-installer --full-installer-version 10.13.6
    

create osx installer usb

  • for Catalina FINAL version
    $ sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/UNTITLED && echo Catalina Boot Drive Created
    
  • for Catalina BETA version
    $ sudo /Applications/Install\ macOS\ Catalina\ Beta.app/Contents/Resources/createinstallmedia --volume /Volumes/UNTITLED && echo Catalina Boot Drive Created
    

boot with macOS USB installer

  • connect the macOS Catalina 10.15 beta install drive to to the Mac you want to install Catalina onto
  • reboot the Mac
  • immediately hold down the OPTION key upon boot, keep holding Option until you see the boot menu
  • choose the macOS Catalina 10.15 beta installer volume to boot from

Convert a MacOS Installer to ISO

  • download MacOS Mojave installer, or the MacOS Catalina installer (or the installer you wish to turn into an ISO) from the Mac App Store, untill the “Install MacOS Mojave.app” or “Install MacOS Catalina.app” application is fully downloaded and within the /Applications folder, proceed

  • open the Terminal application, create a disk image DMG file via:

    $ hdiutil create -o /tmp/Mojave -size 8500m -volname Mojave -layout SPUD -fs HFS+J
    
  • mount the created DMG disk image via:

    $ hdiutil attach /tmp/Mojave.dmg -noverify -mountpoint /Volumes/Mojave
    
  • use createinstallmedia to create the macOS installer application on the mounted volume:

    $ sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/Mojave --nointeraction
    
  • unmount the volume just created:

    $ hdiutil detach /volumes/Install\ macOS\ Mojave
    
  • convert the DMG disk image file to an ISO disk image file (technically a CDR file but it’s the same as an iso)

    $ hdiutil convert /tmp/Mojave.dmg -format UDTO -o ~/Desktop/Mojave.cdr
    
  • rename the CDR file extension to ISO to convert the CDR to ISO:

    $ mv ~/Desktop/Mojave.cdr ~/Desktop/Mojave.iso
    

flushed

[!NOTE|label:references:]

disk cache

$ sudo purge

flush DNS

[!NOTE|label:references:]

$ sudo killall -HUP mDNSResponder
# or
$ sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say cache flushed
  • ventura & monterey

    $ sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    
  • lion, mountain lion, mavericks, el capitan, sierra, high sierra, mojave

    $ sudo killall -HUP mDNSResponder
    
  • yosemite

    $ sudo discoveryutil mdnsflushcache
    
  • tiger

    $ lookupd -flushcache
    

clean OSX native dot file

$ dot_clean -mvp <path>
  • i.e.:

    $ sudo dot_clean -mvp /
    
  • or

    $ /usr/local/bin/rg --hidden --smart-case --color=never --files "$HOME" -g '*\.DS_*' | xargs -r rm
    # or
    $ /usr/local/bin/fd -Iu --glob '*\.DS_*' $HOME | xargs -r rm
    
    $ find $HOME -name '.DS_Store' -type f -delete
    # or
    $ find / -name '._*' -type f -delete
    # or
    $ find / -name '._*' -type f -size -4k -delete
    
  • or disable indexing

    $ sudo mdutil -i off /Volumes/<diskName>
    
  • or all-in-all actions

    [!NOTE|label:references:]

    $ sudo defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
    $ sudo mdutil -i off /Volumes/<FS NAME>
    $ sudo rm -rf .{DS_Store,fseventsd,Spotlight-V*,Trashes}
    
  • for windows

    > cd c:\path\to\folder
    > del /s /q /f /a .DS_STORE
    > del /s /q /f /a:h ._*
    
  • flush DNS

    $ ipconfig /flushdns
    

launchctl

create new plist

cat > ~/Library/LaunchAgents/i.marslo.updatedb.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>i.marslo.updatedb</string>
  <key>ProgramArguments</key>
  <array>
    <string>sudo</string>
    <string>/usr/local/bin/gupdatedb</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>StandardErrorPath</key>
  <string>/Users/marslo/.marslo/log/i.marslo.updatedb.log</string>
  <key>StandardOutPath</key>
  <string>/Users/marslo/.marslo/log/i.marslo.updatedb.error.log</string>
  <key>StartInterval</key>
  <integer>300</integer>
  <key>KeepAlive</key>
  <true/>
</dict>
</plist>
EOF
  • check
    $ plutil ~/Library/LaunchAgents/i.marslo.updatedb.plist
    /Users/marslo/Library/LaunchAgents/i.marslo.updatedb.plist: OK
    
  • enable
    $ launchctl load ~/Library/LaunchAgents/i.marslo.updatedb.plist
    $ launchctl list | grep updatedb
    - 1 i.marslo.updatedb
    
  • disable
    $ launchctl remove i.marslo.updatedb
    

Q&A

SUPreferenceManager: Failed to set object of class: __NSCFString

  • issue:
    $ softwareupdate --fetch-full-installer
    Downloading and installing com.apple.InstallAssistant.macOSBigSur installer
    SUPreferenceManager: Failed to set object of class: __NSCFString for key: LastRecommendedMajorOSBundleIdentifier with error: Error Domain=SUPreferenceManagerErrorDomain Code=1 "(null)"
    SUPreferenceManager: Failed to set object of class: __NSCFString for key: LastRecommendedMajorOSBundleIdentifier with error: Error Domain=SUPreferenceManagerErrorDomain Code=1 "(null)"
    SUPreferenceManager: Failed to set object of class: __NSCFString for key: LastRecommendedMajorOSBundleIdentifier with error: Error Domain=SUPreferenceManagerErrorDomain Code=1 "(null)"
    Installing: 90.0%SUPreferenceManager: Failed to set object of class: __NSCFString for key: LastRecommendedMajorOSBundleIdentifier with error: Error Domain=SUPreferenceManagerErrorDomain Code=1 "(null)"
    Install failed with error: 0
    
Copyright © marslo 2020-2023 all right reserved,powered by GitbookLast Modified: 2024-03-12 15:01:28

results matching ""

    No results matching ""