Skip to content

Instantly share code, notes, and snippets.

@ThePredators
Last active November 8, 2024 23:15
Show Gist options
  • Save ThePredators/cd9812dcb9c43f2fa87fc517d5921185 to your computer and use it in GitHub Desktop.
Save ThePredators/cd9812dcb9c43f2fa87fc517d5921185 to your computer and use it in GitHub Desktop.
[macOS] usefull CLI

🔥 macOS (CheatSheet)

Apple Usefull Links :

🔥 macOS Usefull CLI

Make ISO file from any Folder

hdiutil makehybrid -iso -joliet -o <FILENAME>.iso <FOLDER_PATH>

Clone a hard drive (ex. Windows)

# this command give the list of available drives
diskutil list

# Unmount the source & destination drive (ex. disk9 disk4)
diskutil unmountDisk /dev/disk9
diskutil unmountDisk /dev/disk4

# clone from disk9 to disk4
sudo dd if=/dev/disk9 of=/dev/disk4 status=progress conv=noerror,sync bs=64k

# eject disk
diskutil eject /dev/disk4

If you install an App & You're not able to run it use this :

# example with librewolf
xattr -cr /Applications/LibreWolf.app 

Enable in Security / Confidentiality the Install From everywhere Button

sudo spctl --master-disable

Show Hidden Files

defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder

Hide Hidden Files

defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder

Show file + Extension

defaults write NSGlobalDomain AppleShowAllExtensions -bool true; killall Finder

Hide file Extension

defaults write NSGlobalDomain AppleShowAllExtensions -bool false; killall Finder

Display IP Address (Private)

ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\  -f2

Display IP Address (Public)

dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com

Flush DNS

dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Run Software Updates

softwareupdate --all --install --force 
# add this flag to restart computer after installing updates : --restart

## If the above command showed no update
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

🔥 macOS Apple Store CLI MAS

Install tools

brew install mas

Search

mas search Spark

Download

mas install <ByID>

🔥 macOS Downloader

This command will allow you to download any macOS installer App ! Just name a version and you are good to go.

## Intel OSX
Version 10.0: "Cheetah" (last stable: 10.0.4)
Version 10.1: "Puma" (last stable: 10.1.5)
Version 10.2: "Jaguar" (last stable: 10.2.8)
Version 10.3: "Panther" (last stable: 10.3.9)
Version 10.4: "Tiger" (last stable: 10.4.11)
Version 10.5: "Leopard" (last stable: 10.5.8)
Version 10.6: "Snow Leopard" (last stable: 10.6.8)
Version 10.7: "Lion" (last stable: 10.7.5)
Version 10.8: "Mountain Lion" (last stable: 10.8.5)
Version 10.9: "Mavericks" (last stable: 10.9.5)
Version 10.10: "Yosemite" (last stable: 10.10.5)
Version 10.11: "El Capitan" (last stable: 10.11.6)
Version 10.12: "Sierra" (last stable: 10.12.6)
Version 10.13: "High Sierra" (last stable: 10.13.6)
Version 10.14: "Mojave" (last stable: 10.14.6)
Version 10.15: "Catalina" (last stable: 10.15.7)

## Apple Silicon macOS (& intel but till when :/)
Version 11: "Big Sur" (last stable: 11.7.10)
Version 12: "Monterey" (last stable: 12.7.4)
Version 13: "Ventura" (last stable: 13.7.1)
Version 14: "Sonoma" (last stable: 14.7.1)
Version 14: "Sequoia" (last stable: 15.1)

To get Latest version & details about any macOS version use this link : https://en.wikipedia.org/wiki/MacOS_<REPLACE_WITH_MACOS_VERSION_NAME> (ex. https://en.wikipedia.org/wiki/MacOS_Sonoma) (If the name contains space replace with _ !)

(macOS 11+):

Using Mist-CLI or Mist GUI

# Install Mist-CLI
brew install mist

# List installer
mist list installer

# Ex. Download macOS 12.6.6 ".App"
sudo mist download installer "12.6.6" application

(macOS <11) :

List available installers

softwareupdate --list-full-installers

Upgrade command

softwareupdate --fetch-full-installer --full-installer-version "10.15.7"

Other usefull CLI :

Make a Bootable IMG

## New way
sudo <PATH_TO>/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/<VOLUME_NAME> --nointeraction

## Old Way
sudo <PATH_TO>/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/<VOLUME_NAME> --applicationpath <PATH_TO>/Install\ OS\ X\ El\ Capitan.app

Tips :

Usefull Symboles

⌘ is the Command () key.
⌃ is the Control key.
⌥ is the Option (alt) key.
⇧ is the Shift key.
⇪ is the Caps Lock key.

What does InstallMacOSX.dmg ?

- InstallMacOSX.dmg (double-click on it) it will open to the InstallMacOSX.pkg
- Double-click on the InstallMacOSX.pkg and an installation window will open, this creates the "Install <NAME_OF_VERSION>.app" in Application folder.
- The Image created will be used for making a bootable image on usb key.

Enjoy :)

@ThePredators
Copy link
Author

Maj 01/2023 :

  • Added scripts to download macOS Installer automatically from terminal

@ThePredators
Copy link
Author

Update 05/2023 :

  • Improved overall documentation
  • Added usefull links
  • Added new way to download macOS
  • Added new scripts

@ThePredators
Copy link
Author

Update 01/2024 :

  • Added some commands to clone a hard drive
  • Added a cmd that unlock installed apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment