John Siu Blog

Tech - Business Tool, Personal Toys

MacOS Command Line

☰ Table of Content

Some MacOS commands.

Run Application from Command Line

Application name is case-sensitive. Use tab for auto-complete.

1
2
open -a <application>
open -a Google\ Earth\ Pro

Show Hidden File in Finder

  • Command+Shift+.

Launch Control

  • List all services

    1
    2
    3
    
    launchctl list # List services
    launchctl load <plist file> # Start service
    launchctl unload <plist file> # Stop service
    
  • List all 3rd-party(non-Apple) services

    1
    
    launchctl list|grep -v com.apple.
    
  • System Service Location

    • /Library/LaunchDaemons/
    • /System/Library/LaunchDaemons/

Kernel Extension

  • List all kernel extension

    1
    
    kextstat
    
  • List all non-Apple extension

    1
    
    kextstat | grep -v com.apple
    

Plist Content

1
plutil -p <file>

Safe Mode

Hold down Shift during boot.

Command line may not work anymore.

  • Enable

    1
    2
    
    sudo nvram boot-args="-x"
    sudo nvram boot-args="-x -v"
    
  • Disable

    1
    
    sudo nvram boot-args=""
    

Network Setup Command

  • Help

    1
    
    networksetup
    
  • List all network service

    1
    
    networksetup -listallnetworkservices
    
  • Turn network service on/off

    1
    2
    3
    
    networksetup -setnetworkserviceenabled <networkservice> <on off>
    networksetup -setnetworkserviceenabled Ethernet off
    networksetup -setnetworkserviceenabled Ethernet on
    

Change Hostname

1
sudo scutil --set HostName <hostname>

Mouse Speed

  • Get

    1
    
    defaults read -g com.apple.mouse.scaling
    
  • Set

    May need reboot.

    1
    
    defaults write -g com.apple.mouse.scaling your_mouse_speed
    

dns-sd (mdns/avahi/bonjour)

Get address of hostname

1
dns-sd -G v4v6 <hostname>

Play Audio

1
afplay <file>

John Siu

Update: 2020-08-19
comments powered by Disqus