cmc/cleberg.net

My personal web garden & blog.

clone: git clone https://gitbay.org/cmc/cleberg.net.git

main: content/garden/macos.org · raw

  1#+title: 🌱 macos
  2#+slug: macos
  3#+description: All about the macOS operating system.
  4#+date: [2026-02-21 Sat 14:01:32]
  5
  6* Delete Annoying ~.DS_Store~ Files
  7
  8A simple command, using ~fd~ to clean up all ~.DS_Store~ files in any directory.
  9
 10#+begin_src sh
 11# Run the command directly
 12fd -H '.DS_Store' -t f -x rm
 13
 14# Or, create an alias for it
 15alias xclean="fd -H '.DS_Store' -t f -x rm"
 16xclean
 17#+end_src
 18
 19* Hardening macOS
 20
 21Ref: [[https://github.com/drduh/macOS-Security-and-Privacy-Guide/blob/master/README.md][macOS Security and Privacy Guide]]
 22
 23#+begin_src sh
 24# Generalize computer name
 25sudo scutil --set ComputerName MacBook
 26sudo scutil --set LocalHostName MacBook
 27
 28# Enable firewall
 29sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
 30sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
 31sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned off
 32sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsignedapp off
 33sudo pkill -HUP socketfilterfw
 34
 35# Use Homebrew for software management
 36/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
 37brew analytics off
 38brew update && brew upgrade
 39
 40# Use a secure and private browser(s)
 41## Harden these manually after installing
 42brew install --cask tor-browser ungoogled-chromium firefox
 43
 44# Use a secure and private messenger
 45## Signal; XMPP (e.g., Monal); Matrix (e.g., Element)
 46brew install --cask signal monal element
 47
 48# GPG
 49## Install
 50brew install gnupg
 51## Use recommended settings
 52curl -o ~/.gnupg/gpg.conf https://raw.githubusercontent.com/drduh/config/main/gpg.conf
 53
 54# Delete Metadata
 55## Bluetooth
 56sudo defaults delete /Library/Preferences/com.apple.Bluetooth.plist DeviceCache
 57sudo defaults delete /Library/Preferences/com.apple.Bluetooth.plist IDSPairedDevices
 58sudo defaults delete /Library/Preferences/com.apple.Bluetooth.plist PANDevices
 59sudo defaults delete /Library/Preferences/com.apple.Bluetooth.plist PANInterfaces
 60sudo defaults delete /Library/Preferences/com.apple.Bluetooth.plist SCOAudioDevices
 61## CUPS
 62sudo rm -rfv /var/spool/cups/c0*
 63sudo rm -rfv /var/spool/cups/tmp/*
 64sudo rm -rfv /var/spool/cups/cache/job.cache*
 65## Connections
 66sudo defaults delete /Users/$USER/Library/Preferences/com.apple.iPod.plist "conn:128:Last Connect"
 67sudo defaults delete /Users/$USER/Library/Preferences/com.apple.iPod.plist Devices
 68sudo defaults delete /Library/Preferences/com.apple.iPod.plist "conn:128:Last Connect"
 69sudo defaults delete /Library/Preferences/com.apple.iPod.plist Devices
 70sudo rm -rfv /var/db/lockdown/*
 71## Quicklook
 72rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/exclusive
 73rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/index.sqlite
 74rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/index.sqlite-shm
 75rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/index.sqlite-wal
 76rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/resetreason
 77rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/thumbnails.data
 78sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/thumbnails.fraghandler
 79sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/exclusive
 80sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/index.sqlite
 81sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/index.sqlite-shm
 82sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/index.sqlite-wal
 83sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/resetreason
 84sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/thumbnails.data
 85sudo rm -rfv $(getconf DARWIN_USER_CACHE_DIR)/com.apple.QuickLook.thumbnailcache/thumbnails.fraghandler
 86rm -rfv "~/Library/Application Support/Quick Look/*"
 87chmod -R 000 "~/Library/Application Support/Quick Look"
 88chflags -R uchg "~/Library/Application Support/Quick Look"
 89## Finder
 90defaults delete ~/Library/Preferences/com.apple.finder.plist FXDesktopVolumePositions
 91defaults delete ~/Library/Preferences/com.apple.finder.plist FXRecentFolders
 92defaults delete ~/Library/Preferences/com.apple.finder.plist RecentMoveAndCopyDestinations
 93defaults delete ~/Library/Preferences/com.apple.finder.plist RecentSearches
 94defaults delete ~/Library/Preferences/com.apple.finder.plist SGTRecentFileSearches
 95## WiFi
 96sudo nvram -d 36C28AB5-6566-4C50-9EBD-CBB920F83843:current-network
 97sudo nvram -d 36C28AB5-6566-4C50-9EBD-CBB920F83843:preferred-networks
 98sudo nvram -d 36C28AB5-6566-4C50-9EBD-CBB920F83843:preferred-count
 99## Typing
100rm -rfv "~/Library/LanguageModeling/*" "~/Library/Spelling/*" "~/Library/Suggestions/*"
101chmod -R 000 ~/Library/LanguageModeling ~/Library/Spelling ~/Library/Suggestions
102chflags -R uchg ~/Library/LanguageModeling ~/Library/Spelling ~/Library/Suggestions
103## Apps
104rm -rfv ~/Library/Saved\ Application\ State/*
105rm -rfv ~/Library/Containers/<APPNAME>/Data/Library/Saved\ Application\ State
106chmod -R 000 ~/Library/Saved\ Application\ State/
107chmod -R 000 ~/Library/Containers/<APPNAME>/Data/Library/Saved\ Application\ State
108chflags -R uchg ~/Library/Saved\ Application\ State/
109chflags -R uchg ~/Library/Containers/<APPNAME>/Data/Library/Saved\ Application\ State
110## Autosave
111rm -rfv "~/Library/Containers/<APP>/Data/Library/Autosave Information"
112rm -rfv "~/Library/Autosave Information"
113chmod -R 000 "~/Library/Containers/<APP>/Data/Library/Autosave Information"
114chmod -R 000 "~/Library/Autosave Information"
115chflags -R uchg "~/Library/Containers/<APP>/Data/Library/Autosave Information"
116chflags -R uchg "~/Library/Autosave Information"
117## Siri Analytics
118rm -rfv ~/Library/Assistant/SiriAnalytics.db
119chmod -R 000 ~/Library/Assistant/SiriAnalytics.db
120chflags -R uchg ~/Library/Assistant/SiriAnalytics.db
121## iTunes
122defaults delete ~/Library/Preferences/com.apple.iTunes.plist recentSearches
123## QuickTime
124~/Library/Containers/com.apple.QuickTimePlayerX/Data/Library/Preferences/com.apple.QuickTimePlayerX.plist
125## Misc.
126~/Library/Containers/com.apple.appstore/Data/Library/Preferences/com.apple.commerce.knownclients.plist
127~/Library/Preferences/com.apple.commerce.plist
128~/Library/Preferences/com.apple.QuickTimePlayerX.plist
129#+end_src