本文档来自以下github资源的翻译和整理,一个很棒的框架、库和软件的管理列表。
```bash
defaults write com.apple.universalaccess reduceTransparency -bool true
defaults write com.apple.universalaccess reduceTransparency -bool false ```
```bash
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '/path/to/picture.jpg'" && killall Dock ```
```bash
find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |\sed 's#.app/Contents/_MASReceipt/receipt#.app#g; s#/Applications/##'
mdfind kMDItemAppStoreHasReceipt=1 ```
Works up to Yosemite. ```bash
defaults write com.apple.appstore ShowDebugMenu -bool true
defaults write com.apple.appstore ShowDebugMenu -bool false ```
bash
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -help
```bash
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -restart -agent -console
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -stop ```
```bash
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off ```
bash
sudo rm -rf /var/db/RemoteManagement ; \
sudo defaults delete /Library/Preferences/com.apple.RemoteDesktop.plist ; \
defaults delete ~/Library/Preferences/com.apple.RemoteDesktop.plist ; \
sudo rm -r /Library/Application\ Support/Apple/Remote\ Desktop/ ; \
rm -r ~/Library/Application\ Support/Remote\ Desktop/ ; \
rm -r ~/Library/Containers/com.apple.RemoteDesktop
```bash
defaults write com.apple.addressbook ABShowDebugMenu -bool true
defaults write com.apple.addressbook ABShowDebugMenu -bool false ```
bash
~/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/ksinstall --nuke
This works up to Yosemite. System Integrity Protection was introduced in El Capitan which prevents system Launch Agents from being unloaded. ```bash
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist
launchctl load -w /System/Library/LaunchAgents/com.apple.rcd.plist ```
From El Capitan onwards, 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.
bash
sudo chmod 0000 /Applications/iTunes.app
bash
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
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. ```applescript (* Speed up Mail.app by vacuuming the Envelope Index Code from: http://web.archive.org/web/20071008123746/http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/ 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 osversion to do shell script "swvers -productVersion" set mailversion to "V2" considering numeric strings if "10.10" <= osversion then set mailversion to "V3" if "10.12" <= osversion then set mailversion to "V4" if "10.13" <= osversion then set mailversion to "V5" if "10.14" <= osversion then set mail_version to "V6" end considering
set sizeBefore to do shell script "ls -lnah ~/Library/Mail/" & mailversion & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}" do shell script "/usr/bin/sqlite3 ~/Library/Mail/" & mailversion & "/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 ```
bash
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2StandardFontFamily Georgia
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFontSize 16
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2FixedFontFamily Menlo
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DefaultFixedFontSize 14
bash
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true && \
defaults write com.apple.Safari IncludeDevelopMenu -bool true && \
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true && \
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true && \
defaults write -g WebKitDeveloperExtras -bool true
Other options: get source
, get text
.
bash
osascript -e 'tell application "Safari" to get URL of current tab of front window'
```bash
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool YES
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool NO ```
bash
defaults write com.bohemiancoding.sketch3 exportCompactSVG -bool yes
Removes the dialog and defaults to auto reload.
bash
defaults write -app Skim SKAutoReloadFileUpdate -boolean true
```bash
defaults write com.apple.Terminal FocusFollowsMouse -string YES
defaults write com.apple.Terminal FocusFollowsMouse -string NO ```
bash
defaults write com.apple.TextEdit RichText -int 0
bash
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
This changes the interval to 30 minutes. The integer value is the time in seconds.
bash
sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 1800
Whether Time Machine performs local backups while the Time Machine backup volume is not available. ```bash
defaults read /Library/Preferences/com.apple.TimeMachine MobileBackups
sudo tmutil enablelocal
sudo tmutil disablelocal ```
Since 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.
bash
sudo defaults write /Library/Preferences/com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
This little script will output the last 12 hours of Time Machine activity followed by live activity. ```bash
filter='processImagePath contains "backupd" and subsystem beginswith "com.apple.TimeMachine"'
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" ```
```bash
sudo defaults read /Library/Preferences/com.apple.TimeMachine RequiresACPower
sudo defaults write /Library/Preferences/com.apple.TimeMachine RequiresACPower -bool true
sudo defaults write /Library/Preferences/com.apple.TimeMachine RequiresACPower -bool false ```
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.
bash
sudo tmutil verifychecksums /path/to/backup
Compiling MacVim via Homebrew with all bells and whistles, including overriding system Vim.
bash
brew install macvim --HEAD --with-cscope --with-lua --with-override-system-vim --with-luajit --with-python
Install the modern Vim drop-in alternative via Homebrew.
bash
brew install neovim
bash
xcode-select --install
bash
xcrun simctl delete unavailable
bash
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' && \
killall Dock
bash
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = {}; "tile-type"="small-spacer-tile"; }' && \
killall Dock
bash
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' && \
killall Dock
bash
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="small-spacer-tile";}' && \
killall Dock
```bash
defaults write com.apple.dock mru-spaces -bool true && \ killall Dock
defaults write com.apple.dock mru-spaces -bool false && \ killall Dock ```
Global setting whether Dock icons should bounce when the respective application demands your attention. ```bash
defaults write com.apple.dock no-bouncing -bool true && \ killall Dock
defaults write com.apple.dock no-bouncing -bool false && \ killall Dock ```
```bash
defaults write com.apple.Dock size-immutable -bool yes && \ killall Dock
defaults write com.apple.Dock size-immutable -bool no && \ killall Dock ```
bash
defaults delete com.apple.dock && \
killall Dock
Fully resize your Dock's body. To resize change the 0
value as an integer.
bash
defaults write com.apple.dock tilesize -int 0 && \
killall Dock
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. ```bash
defaults write com.apple.dock scroll-to-open -bool true && \ killall Dock
defaults write com.apple.dock scroll-to-open -bool false && \ killall Dock ```
bash
defaults write com.apple.dock autohide -bool true && \
killall Dock
The float number defines the show/hide delay in ms.
bash
defaults write com.apple.dock autohide-time-modifier -float 0.4 && \
defaults write com.apple.dock autohide-delay -float 0 && \
killall Dock
```bash
defaults write com.apple.dock showhidden -bool true && \ killall Dock
defaults write com.apple.dock showhidden -bool false && \ killall Dock ```
```bash
defaults write com.apple.dock static-only -bool true && \ killall Dock
defaults write com.apple.dock static-only -bool false && \ killall Dock ```
Supported formats are plain text, rich text (rtf) and Microsoft Word (doc/docx).
bash
textutil -convert html file.ext
Creates an empty 10 gigabyte test file.
bash
mkfile 10g /path/to/file
Leaving this turned on is useless when you're using SSDs.
bash
sudo pmset -a sms 0
The only reliable way to do this is by sending an AppleScript command to Finder.
bash
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'
You don't have to use the Disk Utility GUI for this.
bash
sudo diskutil repairPermissions /
Beginning with OS X El Capitan, system file permissions are automatically protected. It's no longer necessary to verify or repair permissions with Disk Utility. (Source)
```bash
bless --mount "/path/to/mounted/volume" --setBoot
sudo systemsetup -setstartupdisk /System/Library/CoreServices ```
bash
diskutil list
A continuous stream of file system access info.
bash
sudo fs_usage
Available since High Sierra. There is no central utility and usage is inconsistent as most functionality is rolled into tmutil
.
bash
/System/Library/Filesystems/apfs.fs/Contents/Resources/hfs_convert /path/to/file/system
bash
/System/Library/Filesystems/apfs.fs/Contents/Resources/newfs_apfs /path/to/device
bash
tmutil localsnapshot
```bash tmutil deletelocalsnapshots com.apple.TimeMachine.2018-01-26-044042 ````
bash
tmutil listlocalsnapshots /
Snapshots are read-only.
bash
mkdir ~/mnt
/System/Library/Filesystems/apfs.fs/Contents/Resources/mount_apfs -s com.apple.TimeMachine.2018-01-26-044042 / ~/mnt
bash
hdiutil create -volname "Volume Name" -srcfolder /path/to/folder -ov diskimage.dmg
If you'd like to encrypt the disk image:
bash
hdiutil create -encryption -stdinpass -volname "Volume Name" -srcfolder /path/to/folder -ov encrypted.dmg
By default, you'll be prompted for a password. You can automate that by piping in a password:
bash
echo -n YourPassword | hdiutil create -encryption -stdinpass -volname "Volume Name" -srcfolder /path/to/folder -ov encrypted.dmg
This command applies to .iso, .img and .dmg images.
bash
hdiutil burn /path/to/image_file
bash
defaults write com.apple.frameworks.diskimages skip-verify -bool true && \
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true && \
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
bash
bless --folder "/path/to/mounted/volume/System/Library/CoreServices" --bootinfo --bootefi
bash
hdiutil attach /path/to/diskimage.dmg
bash
hdiutil detach /dev/disk2s1
Like the Disk Utility "Restore" function.
bash
sudo asr -restore -noverify -source /path/to/diskimage.dmg -target /Volumes/VolumeToRestoreTo
External HDs, thumb drives, etc. ```bash
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true && \ killall Finder
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false && \ killall Finder ```
Built-in HDs or SSDs. ```bash
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true && \ killall Finder
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false && \ killall Finder ```
CDs, DVDs, iPods, etc. ```bash
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true && \ killall Finder
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false && \ killall Finder ```
AFP, SMB, NFS, WebDAV, etc. ```bash
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true && \ killall Finder
defaults write com.apple.finder ShowMountedServersOnDesktop -bool false && \ killall Finder ```
bash
sudo chmod -RN /path/to/folder
bash
chflags hidden /path/to/folder/
bash
defaults write -g AppleShowAllExtensions -bool true
```bash
defaults write com.apple.finder AppleShowAllFiles true
defaults write com.apple.finder AppleShowAllFiles false ```
bash
sudo chflags -R nouchg /path/to/file/or/folder
bash
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
bash
chflags nohidden ~/Library
bash
defaults write -g NSNavRecentPlacesLimit -int 10 && \
killall Finder
Makes possible to see Finder menu item "Quit Finder" with default shortcut Cmd + Q ```bash
defaults write com.apple.finder QuitMenuItem -bool true && \ killall Finder
defaults write com.apple.finder QuitMenuItem -bool false && \ killall Finder ```
Useful if you’re on an older Mac that messes up the animation. ```bash
defaults write -g NSScrollAnimationEnabled -bool false
defaults write -g NSScrollAnimationEnabled -bool true ```
```bash
defaults write -g NSScrollViewRubberbanding -bool false
defaults write -g NSScrollViewRubberbanding -bool true ```
bash
defaults write -g NSNavPanelExpandedStateForSaveMode -bool true && \
defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true
```bash
defaults write com.apple.finder CreateDesktop -bool false && \ killall Finder
defaults write com.apple.finder CreateDesktop -bool true && \ killall Finder ```
```bash
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder ShowPathbar -bool false ```
Possible values: WhenScrolling
, Automatic
and Always
.
bash
defaults write -g AppleShowScrollBars -string "Always"
```bash
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowStatusBar -bool false ```
Sets default save target to be a local disk, not iCloud.
bash
defaults write -g NSDocumentSaveNewDocumentsToCloud -bool false
bash
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
bash
defaults write com.apple.finder NewWindowTarget -string "PfLo" && \
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
Sets size to 'medium'.
bash
defaults write -g NSTableViewDefaultSizeMode -int 2
Avoids creation of .DS_Store
and AppleDouble files.
bash
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
Avoids creation of .DS_Store
and AppleDouble files.
bash
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
If multiple windows are open, it chooses the top-most one.
bash
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
bash
open https://github.com
bash
open README.md
You can open applications using -a
.
bash
open -a "Google Chrome" https://github.com
bash
open /path/to/folder/
bash
open .
To clear font caches for all users, put sudo
in front of this command.
bash
atsutil databases -removeUser && \
atsutil server -shutdown && \
atsutil server -ping
You need to download and install Xcode 8 beta for this to work. Afterwards they should be available in all applications.
bash
cp -v /Applications/Xcode-beta.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/Fonts/SFMono-* ~/Library/Fonts
From Sierra onward, they are included in Terminal.app.
bash
cp -v /Applications/Utilities/Terminal.app/Contents/Resources/Fonts/SFMono-* ~/Library/Fonts
Please see this file.
```bash
defaults read /Library/Preferences/com.apple.Bluetooth ControllerPowerState
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \ sudo killall -HUP blued ```
Enable Trim for non-Apple SSDs. This command is available since Yosemite.
bash
forcetrim
bash
networksetup -listallhardwareports
bash
pmset -g batt | egrep "([0-9]+\%).*" -o --colour=auto | cut -f1 -d';'
bash
pmset -g batt | egrep "([0-9]+\%).*" -o --colour=auto | cut -f3 -d';'
bash
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p'
bash
system_profiler SPDisplaysDataType | grep Resolution
bash
sysctl -n machdep.cpu.brand_string
```bash
defaults read /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -int 1
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -int 0 ```
Prevent sleep for 1 hour:
bash
caffeinate -u -t 3600
bash
sudo pmset -g
bash
sudo pmset displaysleep 15
bash
sudo pmset sleep 30
bash
sudo systemsetup -getcomputersleep
bash
sudo systemsetup -setcomputersleep 60
bash
sudo systemsetup -setcomputersleep Never
bash
sudo systemsetup -setrestartfreeze on
Play iOS charging sound when MagSafe is connected. ```bash
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true && \ open /System/Library/CoreServices/PowerChime.app
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false && \ killall PowerChime ```
```bash
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool true
defaults read -g NSAutomaticSpellingCorrectionEnabled ```
Enable Tab in modal dialogs. ```bash
defaults write NSGlobalDomain AppleKeyboardUIMode -int 0
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 ```
Disable the default "press and hold" behavior. ```bash
defaults write -g ApplePressAndHoldEnabled -bool false
defaults write -g ApplePressAndHoldEnabled -bool true ```
Sets a very fast repeat rate, adjust to taste.
bash
defaults write -g KeyRepeat -int 0.02
You need to restart Dock
because Launchpad is tied to it.
```bash
rm ~/Library/Application\ Support/Dock/*.db && \ killall Dock
defaults write com.apple.dock ResetLaunchPad -bool true && \ killall Dock ```
bash
afconvert input.mp3 ringtone.m4r -f m4af
Uses "Alex" voice, a plain UTF-8 encoded text file for input and AAC output.
bash
say -v Alex -f file.txt -o "output.m4a"
bash
sudo nvram SystemAudioVolume=" "
bash
osascript -e 'set volume output muted true'
bash
osascript -e 'set volume 4'
You can play all audio formats that are natively supported by QuickTime.
bash
afplay -q 1 filename.mp3
bash
say 'All your base are belong to us!'
bash
defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen 1
```bash
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array-add "-NoMulticastAdvertisements"
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array "/usr/sbin/mDNSResponder" "-launchd" ```
bash
sudo ipconfig set en0 DHCP
bash
ipconfig getpacket en0
bash
sudo dscacheutil -flushcache && \
sudo killall -HUP mDNSResponder
bash
sudo scutil --set ComputerName "newhostname" && \
sudo scutil --set HostName "newhostname" && \
sudo scutil --set LocalHostName "newhostname" && \
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "newhostname"
Switch between network locations created in the Network preference pane. ```bash
scselect
scselect LocationNameFromStatus ```
bash
networksetup -setmanual "Ethernet" 192.168.2.100 255.255.255.0 192.168.2.1
bash
ping -o github.com
bash
traceroute github.com
Prior to macOS Sierra, ssh would present a dialog asking for your passphrase and would offer the option to store it into the keychain. This UI was deprecated some time ago and has been removed.
Instead, a new UseKeychain option was introduced in macOS Sierra allowing users to specify whether they would like for the passphrase to be stored in the keychain. This option was enabled by default on macOS Sierra, which caused all passphrases to be stored in the keychain.
This was not the intended default behavior, so this has been changed in macOS 10.12.2. (Source)
bash ssh-add -K /path/to/private_key
Then add to~/.ssh/config
:bash Host server.example.com IdentityFile /path/to/private_key UseKeychain yes
```bash
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist ```
This outputs all applications currently using port 80.
bash
sudo lsof -i :80
Works if your ISP doesn't replace DNS requests (which it shouldn't).
bash
dig +short myip.opendns.com @resolver1.opendns.com
Alternative that works on all networks.
```bash
curl -s https://api.ipify.org && echo
````
Files will be served from /private/tftpboot
.
bash
sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist && \
sudo launchctl start com.apple.tftpd
bash
networksetup -setairportnetwork en0 WIFI_SSID WIFI_PASSWORD
Create a symbolic link to the airport command for easy access:
bash
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
Run a wireless scan:
bash
airport -s
bash
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
bash
ipconfig getifaddr en0
bash
defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences | grep LastConnected -A 7
Exchange SSID with the SSID of the access point you wish to query the password from.
bash
security find-generic-password -D "AirPort network password" -a "SSID" -gw
bash
networksetup -setairportpower en0 on
bash
cancel -a -
bash
defaults write -g PMPrintingExpandedStateForPrint -bool true && \
defaults write -g PMPrintingExpandedStateForPrint2 -bool true
bash
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
```bash
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off ```
bash
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /path/to/file
bash
spctl --add /path/to/Application.app
bash
spctl --remove /path/to/Application.app
```bash
spctl --status
sudo spctl --master-enable
sudo spctl --master-disable ```
bash
LC_ALL=C tr -dc "[:alnum:]" < /dev/urandom | head -c 20 | pbcopy
```bash
open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine ```
bash
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
```bash
defaults read com.apple.screensaver askForPasswordDelay
defaults write com.apple.screensaver askForPasswordDelay -int 0
defaults write com.apple.screensaver askForPasswordDelay -int 10 ```
```bash
defaults read com.apple.screensaver askForPassword
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPassword -int 0 ```
Note: The srm
command appears to have been removed on MacOS after 10.9. There is a note on an Apple support page hinting as to why:
With an SSD drive, Secure Erase and Erasing Free Space are not available in Disk Utility. These options are not needed for an SSD drive because a standard erase makes it difficult to recover data from an SSD.
bash
srm /path/to/file
bash
srm -r /path/to/folder/
bash
srm -rf /path/to/complete/destruction
bash
find . -type f -name '*.DS_Store' -ls -delete
bash
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
The -i
modifier makes the search case insensitive.
bash
locate -i *.jpg
```bash
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
defaults remove com.apple.NetworkBrowser DisableAirDrop
defaults write com.apple.NetworkBrowser DisableAirDrop -bool YES ```
bash
osascript /path/to/script.scpt
bash
diff -qr /path/to/folder1 /path/to/folder2
Make sure you have pv
installed and replace /dev/rdisk2
with the appropriate write device or file.
bash
FILE=/path/to/file.iso pv -s $(du -h $FILE | awk '/.*/ {print $1}') $FILE | sudo dd of=/dev/rdisk2 bs=1m
In case your shell session went insane (some script or application turned it into a garbled mess).
bash
stty sane
bash
sudo reboot
bash
sudo poweroff
bash
sw_vers
How long since your last restart.
bash
uptime
bash
cat whatever.txt | pbcopy
bash
pbpaste | textutil -convert txt -stdin -stdout -encoding 30 | pbcopy
bash
pbpaste | expand | pbcopy
bash
pbpaste > whatever.txt
bash
pbpaste | sort | uniq | pbcopy
If FileVault is enabled on the current volume, it restarts the system, bypassing the initial unlock. The command may not work on all systems.
bash
sudo fdesetup authrestart
```bash
sudo fdesetup status
sudo fdesetup enable
sudo fdesetup disable ```
bash
sudo sysdiagnose -f ~/Desktop/
```bash
sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ macOS\ High\ Sierra.app
sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ macOS\ Sierra.app
sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app
sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ Yosemite.app ```
bash
sudo kextstat -l
bash
sudo kextload -b com.apple.driver.ExampleBundle
bash
sudo kextunload -b com.apple.driver.ExampleBundle
Please see this file.
To be independent of OS X version, this relies on locate
to find lsregister
. If you do not have your locate
database built yet, do it.
bash
sudo $(locate lsregister) -kill -seed -r
bash
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Your text"
bash
sudo purge
```bash
vm_stat
vm_stat -c 10 1 ```
```bash
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && \ killall -9 NotificationCenter
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist ```
bash
qlmanage -p /path/to/file
```bash
sudo systemsetup -getremoteappleevents
sudo systemsetup -setremoteappleevents on
sudo systemsetup -setremoteappleevents off ```
```bash
dsenableroot
dsenableroot -d ```
```bash
nvram boot-args
sudo nvram boot-args="-x"
sudo nvram boot-args="" ```
Takes a screenshot as JPEG after 3 seconds and displays in Preview.
bash
screencapture -T 3 -t jpg -P delayedpic.jpg
Sets location to ~/Desktop
.
bash
defaults write com.apple.screencapture location ~/Desktop && \
killall SystemUIServer
Sets format to png
. Other options are bmp
, gif
, jpg
, jpeg
, pdf
, tiff
.
bash
defaults write com.apple.screencapture type -string "png"
bash
defaults write com.apple.screencapture disable-shadow -bool true && \
killall SystemUIServer
Date and time remain unchanged.
bash
defaults write com.apple.screencapture name "Example name" && \
killall SystemUIServer
bash
installer -pkg /path/to/installer.pkg -target /
bash
sudo softwareupdate -ia
Set to check daily instead of weekly.
bash
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
bash
sudo softwareupdate -l
This should only be done for testing purposes or unmanaged clients. To use network-wide, either correctly set up DNS along with Apple SUS service and bind your clients via OpenDirectory. Alternatively, use Reposado together with correct network DNS settings to make resolution transparent. Margarita looks nice to have as well. ```bash
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://su.example.com:8088/index.sucatalog
sudo defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL ```
bash
sw_vers -productVersion
```bash
mdutil -i off -d /path/to/volume
mdutil -i on /path/to/volume ```
bash
mdutil -E /path/to/volume
bash
mdfind -name 'searchterm'
bash
mdls /path/to/file
Reboot while holding Cmd + R, open the Terminal application and enter:
bash
csrutil disable && reboot
Reboot while holding Cmd + R, open the Terminal application and enter:
bash
csrutil enable && reboot
bash
sudo systemsetup -listtimezones
bash
sudo systemsetup -settimezone Europe/Berlin
```bash
sudo systemsetup getusingnetworktime
sudo systemsetup setusingnetworktime on
sudo systemsetup setusingnetworktime off ```
Rings the terminal bell (if enabled) and puts a badge on it.
bash
tput bel
Install the latest version and set as current user's default shell:
bash
brew install bash && \
echo $(brew --prefix)/bin/bash | sudo tee -a /etc/shells && \
chsh -s $(brew --prefix)/bin/bash
Install the latest version and set as current user's default shell:
bash
brew install fish && \
echo $(brew --prefix)/bin/fish | sudo tee -a /etc/shells && \
chsh -s $(brew --prefix)/bin/fish
Install the latest version and set as current user's default shell:
bash
brew install zsh && \
sudo sh -c 'echo $(brew --prefix)/bin/zsh >> /etc/shells' && \
chsh -s $(brew --prefix)/bin/zsh
Version | Codename | Release Date | Most Recent Version -------------------------- | ------------------ | ------------------ | ------------------------------------- Rhapsody Developer Release | Grail1Z4 / Titan1U | August 31, 1997 | DR2 (May 14, 1998) Mac OS X Server 1.0 | Hera | March 16, 1999 | 1.2v3 (October 27, 2000) Mac OS X Developer Preview | n/a | March 16, 1999 | DP4 (April 5, 2000) Mac OS X Public Beta | Kodiak | September 13, 2000 | n/a Mac OS X 10.0 | Cheetah | March 24, 2001 | 10.0.4 (June 22, 2001) Mac OS X 10.1 | Puma | September 25, 2001 | 10.1.5 (June 6, 2002) Mac OS X 10.2 | Jaguar | August 24, 2002 | 10.2.8 (October 3, 2003) Mac OS X 10.3 | Panther | October 24, 2003 | 10.3.9 (April 15, 2005) Mac OS X 10.4 | Tiger | April 29, 2005 | 10.4.11 (November 14, 2007) Mac OS X 10.5 | Leopard | October 26, 2007 | 10.5.8 (August 5, 2009) Mac OS X 10.6 | Snow Leopard | August 28, 2009 | 10.6.8 v1.1 (July 25, 2011) Mac OS X 10.7 | Lion | July 20, 2011 | 10.7.5 (September 19, 2012) OS X 10.8 | Mountain Lion | July 25, 2012 | 10.8.5 (12F45) (October 3, 2013) OS X 10.9 | Mavericks | October 22, 2013 | 10.9.5 (13F1112) (September 18, 2014) OS X 10.10 | Yosemite | October 16, 2014 | 10.10.5 (14F27) (August 13, 2015) OS X 10.11 | El Capitan | September 30, 2015 | 10.11.6 (15G31) (July 18, 2016) macOS 10.12 | Sierra | September 20, 2016 | 10.12.6 (16G29) (July 19, 2017) macOS 10.13 | High Sierra | September 25, 2017 | 10.13.6 (17G65) (July 9, 2018) macOS 10.14 | Mojave | September 24, 2018 | 10.14 (18A391) (September 24, 2018)
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.