Courses & TutorialsOperating System

Awesome MacOs Command Line – Massive Collection Of Shell Commands – You Ever Wondered To Get!

Spread the love

A curated list of shell commands and tools specific to OS X.

“You don’t have to know everything. You simply need to know where to find it when necessary.” (John Brunner)


If you want to contribute, you are highly encouraged to do so. Please read the contribution guidelines.

For more terminal shell goodness, please also see this list’s sister list Awesome Command Line Apps.


When you find something helpful in here, you could buy me a coffee. I spend a lot of time and effort on curating this list. Keeping me properly caffeinated accelerates things. And it would really make my day. Kindness of strangers and all that. If you can’t or won’t, no hard feelings. It’s available completely free for a reason. Still, it would be awesome.


There’s really only one thing I’d like to note here: man pages. Man pages. Man pages. Okay, three things. But this one thing seemed so important, I had to mention it multiple times. If you’re not doing it already, you should get into the habit of consulting man pages before searching anywhere else. Unix-style man pages are an excellent source of documentation. There’s even a man page for the man command itself:

man man

It also explains what the numbers in the man pages refer to — like man(1).



Subpixel Anti-Aliasing (Font Smoothing)

Setting present since macOS 10.14 (Mojave).

# Enable
defaults write -g CGFontRenderingFontSmoothingDisabled -bool false

# Disable (Default)
defaults write -g CGFontRenderingFontSmoothingDisabled -bool true

# Per Application
defaults write CGFontRenderingFontSmoothingDisabled -bool false

# Revert for Application
defaults delete CGFontRenderingFontSmoothingDisabled


Transparency in Menu and Windows

# Reduce Transparency
defaults write reduceTransparency -bool true

# Restore Default Transparency
defaults write reduceTransparency -bool false


Set Wallpaper

# Up to OS X 10.8 (Mountain Lion)
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'

# Since OS X 10.9 (Mavericks)
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '/path/to/picture.jpg'" && killall Dock


App Store

List All Apps Downloaded from App Store

# Via find
find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |\sed '; s#/Applications/##'

# Via Spotlight
mdfind kMDItemAppStoreHasReceipt=1

Show Debug Menu

Works up to OS X 10.10 (Yosemite).

# Enable
defaults write ShowDebugMenu -bool true

# Disable (Default)
defaults write ShowDebugMenu -bool false

Apple Remote Desktop

Kickstart Manual Pages

sudo /System/Library/CoreServices/RemoteManagement/ -help

Activate And Deactivate the ARD Agent and Helper

# Activate And Restart the ARD Agent and Helper
sudo /System/Library/CoreServices/RemoteManagement/ -activate -restart -agent -console

# Deactivate and Stop the Remote Management Service
sudo /System/Library/CoreServices/RemoteManagement/ -deactivate -stop

Remote Desktop Sharing

# Allow Access for All Users and Give All Users Full Access
sudo /System/Library/CoreServices/RemoteManagement/ -configure -allowAccessFor -allUsers -privs -all

# Disable ARD Agent and Remove Access Privileges for All Users (Default)
sudo /System/Library/CoreServices/RemoteManagement/ -deactivate -configure -access -off

Remove Apple Remote Desktop Settings

sudo rm -rf /var/db/RemoteManagement ; \
sudo defaults delete /Library/Preferences/ ; \
defaults delete ~/Library/Preferences/ ; \
sudo rm -r /Library/Application\ Support/Apple/Remote\ Desktop/ ; \
rm -r ~/Library/Application\ Support/Remote\ Desktop/ ; \
rm -r ~/Library/Containers/


Debug Mode

# Enable
defaults write ABShowDebugMenu -bool true

# Disable (Default)
defaults write ABShowDebugMenu -bool false


Uninstall Google Update

~/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/ksinstall --nuke


Keyboard Media Keys

Works up to OS X 10.10 (Yosemite). System Integrity Protection was introduced in OS X 10.11 (El Capitan) which prevents system Launch Agents from being unloaded.

# Stop Responding to Key Presses
launchctl unload -w /System/Library/LaunchAgents/

# Respond to Key Presses (Default)
launchctl load -w /System/Library/LaunchAgents/

From OS X 10.11 (El Capitan) on, you can either disable SIP or resort to a kind of hack, which will make iTunes inaccessible to any user, effectively preventing it from starting itself or its helpers. Be aware that for all intents and purposes this will trash your iTunes installation and may conflict with OS updates down the road.

sudo chmod 0000 /Applications/


Show Attachments as Icons

defaults write DisableInlineAttachmentViewing -bool yes

Vacuum Mail Index

The AppleScript code below will quit Mail, vacuum the SQLite index, then re-open Mail. On a large email database that hasn’t been optimized for a while, this can provide significant improvements in responsiveness and speed.

Speed up by vacuuming the Envelope Index
Code from:
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compatibility
Updated by Andrei Miclaus 2017 to support V4 in Sierra

tell application "Mail" to quit
set os_version to do shell script "sw_vers -productVersion"
set mail_version to "V2"
considering numeric strings
    if "10.10" <= os_version then set mail_version to "V3"
    if "10.12" <= os_version then set mail_version to "V4"
    if "10.13" <= os_version then set mail_version to "V5"
    if "10.14" <= os_version then set mail_version to "V6"
end considering

set sizeBefore to do shell script "ls -lnah ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
do shell script "/usr/bin/sqlite3 ~/Library/Mail/" & mail_version & "/MailData/Envelope\\ Index vacuum"

set sizeAfter to do shell script "ls -lnah ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"

display dialog ("Mail index before: " & sizeBefore & return & "Mail index after: " & sizeAfter & return & return & "Enjoy the new speed!")

tell application "Mail" to activate


Change Default Fonts

defaults write Georgia
defaults write 16
defaults write Menlo
defaults write 14

Develop Menu and Web Inspector

# Enable
defaults write IncludeInternalDebugMenu -bool true && \
defaults write IncludeDevelopMenu -bool true && \
defaults write WebKitDeveloperExtrasEnabledPreferenceKey -bool true && \
defaults write -bool true && \
defaults write -g WebKitDeveloperExtras -bool true

# Disable (Default)
defaults delete IncludeInternalDebugMenu && \
defaults delete IncludeDevelopMenu && \
defaults delete WebKitDeveloperExtrasEnabledPreferenceKey && \
defaults delete && \
defaults delete -g WebKitDeveloperExtras

Get Current Page Data

Other options: get source, get text.

osascript -e 'tell application "Safari" to get URL of current tab of front window'

Use Backspace/Delete to Go Back a Page

# Enable
defaults write -bool YES

# Disable (Default)
defaults write -bool NO


Export Compact SVGs

defaults write com.bohemiancoding.sketch3 exportCompactSVG -bool yes


Turn Off Auto Reload Dialog

Removes the dialog and defaults to auto reload.

defaults write -app Skim SKAutoReloadFileUpdate -boolean true


Focus Follows Mouse

# Enable
defaults write FocusFollowsMouse -string YES

# Disable (Default)
defaults write FocusFollowsMouse -string NO


Use Plain Text Mode as Default

defaults write RichText -int 0

Visual Studio Code

VSCodeVim Key Repeat

# Enable
defaults write ApplePressAndHoldEnabled -bool false

# Disable (Default)
defaults delete ApplePressAndHoldEnabled

Subpixel Anti-Aliasing

Setting present since macOS 10.14 (Mojave). See also system-wide setting: Subpixel Anti-Aliasing

# Enable
defaults write CGFontRenderingFontSmoothingDisabled -bool false && \
defaults write CGFontRenderingFontSmoothingDisabled -bool false && \
defaults write CGFontRenderingFontSmoothingDisabled -bool false && \
defaults write CGFontRenderingFontSmoothingDisabled -bool false

# Disable (Default)
defaults delete CGFontRenderingFontSmoothingDisabled && \
defaults delete CGFontRenderingFontSmoothingDisabled && \
defaults delete CGFontRenderingFontSmoothingDisabled && \
defaults delete CGFontRenderingFontSmoothingDisabled


Time Machine

Change Backup Interval

This changes the interval to 30 minutes. The integer value is the time in seconds.

sudo defaults write /System/Library/LaunchDaemons/ StartInterval -int 1800

Local Backups

Whether Time Machine performs local backups while the Time Machine backup volume is not available.

# Status
defaults read /Library/Preferences/ MobileBackups

# Enable (Default)
sudo tmutil enablelocal

# Disable
sudo tmutil disablelocal

Since macOS 10.13 (High Sierra), you cannot disable local snapshots. Time Machine now always creates a local APFS snapshot and uses that snapshot as the data source to create a regular backup, rather than using the live disk as the source, as is the case with HFS formatted disks.

Prevent Time Machine from Prompting to Use New Hard Drives as Backup Volume

sudo defaults write /Library/Preferences/ DoNotOfferNewDisksForBackup -bool true

Show Time Machine Logs

This little script will output the last 12 hours of Time Machine activity followed by live activity.


filter='processImagePath contains "backupd" and subsystem beginswith ""'

# show the last 12 hours
start="$(date -j -v-12H +'%Y-%m-%d %H:%M:%S')"

echo ""
echo "[History (from $start)]"
echo ""

log show --style syslog --info --start "$start" --predicate "$filter"

echo ""
echo "[Following]"
echo ""

log stream --style syslog --info --predicate "$filter"

Toggle Backup While on Battery

# Status
sudo defaults read /Library/Preferences/ RequiresACPower

# Enable (Default)
sudo defaults write /Library/Preferences/ RequiresACPower -bool true

# Disable
sudo defaults write /Library/Preferences/ RequiresACPower -bool false

Verify Backup

Beginning in OS X 10.11, Time Machine records checksums of files copied into snapshots. Checksums are not retroactively computed for files that were copied by earlier releases of OS X.

sudo tmutil verifychecksums /path/to/backup



Compile Sane Vim

Compiling MacVim via Homebrew with all bells and whistles, including overriding system Vim.

brew install macvim --HEAD


Install the modern Vim drop-in alternative via Homebrew.

brew install neovim


Install Command Line Tools without Xcode

xcode-select --install

Remove All Unavailable Simulators

xcrun simctl delete unavailable


Add a Stack with Recent Applications

Obsolete since macOS 10.14 (Mojave). See Show Recent Apps.

defaults write persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' && \
killall Dock

Add a Nameless Stack Folder and Small Spacer

defaults write persistent-others -array-add '{ "tile-data" = {}; "tile-type"="small-spacer-tile"; }' && \
killall Dock

Add a Space

defaults write persistent-apps -array-add '{"tile-type"="spacer-tile";}' && \
killall Dock

Add a Small Space

defaults write persistent-apps -array-add '{"tile-type"="small-spacer-tile";}' && \
killall Dock

Auto Rearrange Spaces Based on Most Recent Use

# Enable (Default)
defaults write mru-spaces -bool true && \
killall Dock

# Disable
defaults write mru-spaces -bool false && \
killall Dock

Automatically Hide

# Enable
defaults write autohide -bool true && \
killall Dock

# Disable (Default)
defaults write autohide -bool false && \
killall Dock

Icon Bounce

Global setting whether Dock icons should bounce when the respective application demands your attention.

# Enable (Default)
defaults write no-bouncing -bool true && \
killall Dock

# Disable
defaults write no-bouncing -bool false && \
killall Dock

Lock the Dock Size

# Enable
defaults write size-immutable -bool yes && \
killall Dock

# Disable (Default)
defaults write size-immutable -bool no && \
killall Dock

Reset Dock

defaults delete && \
killall Dock


Fully resize your Dock’s body. To resize change the 0 value as an integer.

defaults write tilesize -int 0 && \
killall Dock

Scroll Gestures

Use your touchpad or mouse scroll wheel to interact with Dock items. Allows you to use an upward scrolling gesture to open stacks. Using the same gesture on applications that are running invokes Exposé/Mission Control.

# Enable
defaults write scroll-to-open -bool true && \
killall Dock

# Disable (Default)
defaults write scroll-to-open -bool false && \
killall Dock

Set Auto Show/Hide Delay

The float number defines the show/hide delay in ms.

defaults write autohide-time-modifier -float 0.4 && \
defaults write autohide-delay -float 0 && \
killall Dock

Show Hidden App Icons

# Enable
defaults write showhidden -bool true && \
killall Dock

# Disable (Default)
defaults write showhidden -bool false && \
killall Dock

Show Only Active Applications

# Enable
defaults write static-only -bool true && \
killall Dock

# Disable (Default)
defaults write static-only -bool false && \
killall Dock

Show Recent Apps

Setting present since macOS 10.14 (Mojave).

# Disable
defaults write show-recents -bool false  && \
killall Dock

# Enable (Default)
defaults write show-recents -bool true && \
killall Dock

Single App Mode

When clicking an application icon in the Dock, the respective windows will come to the front, but all other application windows will be hidden.

# Enable
defaults write single-app -bool true && \
killall Dock

# Disable (Default)
defaults write single-app -bool false && \
killall Dock


Convert File to HTML

Supported formats are plain text, rich text (rtf) and Microsoft Word (doc/docx).

textutil -convert html file.ext


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button