Skip to content

macOS cheatsheet

Basic commands


Put some test in to the clipboard

echo "text to copy" | pbcopy

Copy output of the command to the clipboard

whoami | pbcopy

Copy file to the clipboard from the terminal

pbcopy < ~/path/to/file

Paste from clipboard


Put contents of the clipboard to a file

pbpaste > file-name.txt

Execute clipboard contents in a shell

pbpaste | zsh

Sort content of the clipboard, remove duplicate lines

pbpaste | sort -u | pbcopy

Application entitlements

Check application entitlements

codesign -d -vv --entitlements - /Applications/


Open application from terminal

open -a Notes

Open new instance of the application, even if the app is already running

open -n -a Notes

Open new “fresh” instance - without restoring the state

open -F -n -a Safari

Open file in TextEdit

open -e file.txt

Open finder in current working directory

open .

Reveal the file in Finder instead of opening

open -R test.txt

Open the application hidden

open -a TextEdit -j

Do not bring the application to foreground

open -a TextEdit -g

Open the URL with default app

open -u smb://

Write output of the command to temp file and open it in default text editor

 ls / | open -f

Open a web browser

Open web page in default browser


Open web page in Safari from terminal

open -a Safari

Open file in Safari

open -a Safari file:///Users/user/Downloads/test.html

Additional arguments

  • --args - pass remaining arguments to the opened application
  • --env VAR - add the variable to the environment of the application
  • --stdin PATH - open app with stdin set to PATH
  • --stdout PATH - open app with stdout set to PATH
  • --stderr PATH - open app with stderr set to PATH


Show all files in Finder

defaults write AppleShowAllFiles TRUE
killall Finder

Hide desktop icons

defaults write CreateDesktop -bool false
killall Finder

Extended file attributes

List attributes

List file attributes

xattr -l /path/to/file

List file attributes recursively in current working directory

xattr -lr .

Remove attributes

Remove quarantine from the file

xattr -d /path/to/file

Remove the location where the file was downloaded from

xattr -d /path/to/file

Remove all attributes

xattr -c /path/to/file


mdfind -name .pdf

Limit the scope of the search to specified directory

mdfind -onlyin ~/Documents -name .pdf
mdfind image -onlyin ~/Documents

Print total number of matches

mdfind .pdf -onlyin ~/Documents -count

Disable/enable spotlight

Disable the index

mdutil -i off /

Enable the index

mdutil -i on /

Erase the current Spotlight index

mdutil -E /

Get/set computer name

Get host name

scutil --get HostName

Get local host name

scutil --get LocalHostName

Get computer name

scutil --get ComputerName

Change comupter name

Set fully qualified hostname

sudo scutil --set HostName

Local host name (Bonjour hostname)

sudo scutil --set LocalHostName new-host

Set computer name

sudo scutil --set ComputerName new-host


Execute AppleScript

echo 'do shell script "whoami"' | osascript

Execute JavaScript code

echo '...' | osascript -l JavaScript

Compile script to .app file

osacompile -o script.txt

Compile JavaScript code

osacompile -l JavaScript -o -s test.js

Display notification

osascript -e 'display notification "Hello world" with title "Hello"'


osascript -e 'beep'

Multiple beeps

osascript -e 'beep 5'


Change volume

osascript -e "set volume output volume 50"


osascript -e 'set volume output muted true'
osascript -e "set volume with output muted"


osascript -e 'set volume output muted false'
osascript -e "set volume without output muted"

Convert text to audible speech - say

Say with default voice

say 'hello world'

Specify voice

say -v Wobble 'hello'

Pass text to Say

echo 'hello' | say

Read text from input file

say -f input.txt

Run Say in interactive mode

say -i


File Vault

FileVault status

fdesetup status

List FileVault enabled accounts

fdesetup list

Disable user from FileVault enabled accounts

fdesetup remove -user USERNAME

Encrypted dmg volumes

Mount encrypted dmg:

hdiutil attach file_name.dmg

Create an encrypted volume:

hdiutil create -encryption AES-256 -fs HFS+ -size 1g  encrypted.dmg


Build .pkg file with pre/post install scripts only

pkgbuild --identifier com.example --nopayload --scripts ./example-package/scripts ./simple.pkg


  • --auth - values: root or none
  • --install-location - installation location
  • --info PackageInfo - use PackageInfo file

Universal binary files

Get info about binary file

lipo -info fileName

Detailed information

lipo -detailed_info fileName

List binary architectures

lipo -archs fileName

Create “fat” binary for multiple architectures

lipo -create fileName-arm.bin fileName-amd64.bin -output fileName

Extract given architecture to a separate universal file

lipo -extract arm64 fileName -output fileName.arm64

Remove given architecture from universal file

lipo -remove arm64 fileName -output fileName2

Create a thin output file

lipo -thin arm64 fileName -output fileName.arm64

plutil - property list util

Read plist files

Read plist file in human-readable form

plutil -p /path/to/file.plist

Read plist file, convert it to xml and display to the console

plutil -convert xml1 -o - /path/to/file.plist


List what apps user has in the dock

plutil -p ~/Library/Preferences/

List recently accessed files

plutil -p ~/Library/Preferences/

Display macOS version information

plutil -p /System/Library/CoreServices/SystemVersion.plist


Create an empty plist file in XML format

plutil -create xml1 file.plist

Check plist file syntax

plutil -lint file.plist