Giter Club home page Giter Club logo

osx-optimizer's Introduction

OSX-Optimizer

OSX Optimizer: Optimize MacOS - Shell scripts to speed up your mac boot time, accelerate loading, and prevent unnecessary throttling.

macOS can be heavily modified using the defaults command. In fact, almost every option is accessible via defaults.

A great way to see what ticking and unticking a box in the Settings App is by using:

defaults read > defaults.pre.txt

# *make a change in Settings*

defaults read > defaults.post.txt

diff defaults.pre.txt defaults.post.txt

OSX Optimizations

Below you will find extremely good optimizers, particularly for virtual machines.

Some of the commands are dangerous from a remote access perspective, but they will greatly optimize your VM.

Skip the GUI login screen (at your own risk!)

defaults write com.apple.loginwindow autoLoginUser -bool true

User accounts and root/administrator have different defaults

Disable spotlight indexing on macOS to heavily speed up Virual Instances.

# massively increase virtualized macOS by disabling spotlight.
sudo mdutil -i off -a

# since you can't use spotlight to find apps, you can renable with
# sudo mdutil -i on -a

Disable heavy login screen wallpaper

sudo defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture ""

Enable multi-sessions

sudo /usr/bin/defaults write .GlobalPreferences MultipleSessionsEnabled -bool TRUE

defaults write "Apple Global Domain" MultipleSessionsEnabled -bool true

Disable updates (at your own risk!)

This will prevent macOS from downloading huge updates, filling up your disk space.

Disabling updates heavily speeds up virtualized macOS because the qcow2 image does not grow out of proportion.

# as roots
sudo su
defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool false
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool false
defaults write com.apple.commerce AutoUpdate -bool false
defaults write com.apple.commerce AutoUpdateRestartRequired -bool false
defaults write com.apple.SoftwareUpdate ConfigDataInstall -int 0
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 0
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 0
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 0

Enable osascript over SSH automatically without sshd-keygen warning and full disk access

defaults write com.apple.universalaccessAuthWarning /System/Applications/Utilities/Terminal.app -bool true
defaults write com.apple.universalaccessAuthWarning /usr/libexec -bool true
defaults write com.apple.universalaccessAuthWarning /usr/libexec/sshd-keygen-wrapper -bool true
defaults write com.apple.universalaccessAuthWarning com.apple.Messages -bool true
defaults write com.apple.universalaccessAuthWarning com.apple.Terminal -bool true

Disable screen locking

defaults write com.apple.loginwindow DisableScreenLock -bool true

Show a lighter username/password prompt instead of a list of all the users

defaults write /Library/Preferences/com.apple.loginwindow.plist SHOWFULLNAME -bool true
defaults write com.apple.loginwindow AllowList -string '*'

Disable saving the application state on shutdown

This speeds up boot as the session state (currently opened apps) are not running when you reboot.

This may be slower for you depending on what you are doing.

defaults write com.apple.loginwindow TALLogoutSavesState -bool false

Enable AnyDesk automatically

defaults write com.apple.universalaccessAuthWarning "/Applications/AnyDesk.app" -bool true
defaults write com.apple.universalaccessAuthWarning "/Applications/AnyDesk.app/Contents/MacOS/AnyDesk" -bool true
defaults write com.apple.universalaccessAuthWarning "3::/Applications" -bool true
defaults write com.apple.universalaccessAuthWarning "3::/Applications/AnyDesk.app" -bool true
defaults write com.apple.universalaccessAuthWarning "com.philandro.anydesk" -bool true

Enable remote access (at your own risk!)

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
    -activate \
    -configure \
    -access \
    -off \
    -restart \
    -agent \
    -privs \
    -all \
    -allowAccessFor -allUsers

EXTREMELY INSECURE METHODS (at your own risk!)

These macOS optimizations should only be used in CI/CD, behind a VPN, and with no external connectivity.

This is not a warning, it is absolutely essential, or anyone can just SSH into the remote mac.

If you do any of the below commands on a remote server, you will

Disable passwords globally

  • Everyone is now root
  • No need to type passwords
  • SSH login just hit enter for password

As root:

sudo su
# nuke pam
for PAM_FILE in /etc/pam.d/*; do
    sed -i -e s/required/optional/g "${PAM_FILE}"
    sed -i -e s/sufficient/optional/g "${PAM_FILE}"
done

sudo killall Finder || true sudo killall Dock || true sudo killall mds

Make everyone a sudoer

cd /Users
# add everyone to sudoers and import the control center plist
for REAL_NAME in *; do
    echo "${REAL_NAME}"
    tee "/etc/sudoers.d/${REAL_NAME}" <<< "${REAL_NAME}     ALL=(ALL)       NOPASSWD: ALL"
    # sudo -u "${REAL_NAME}" defaults write -globalDomain NSUserKeyEquivalents  -dict-add "Save as PDF\\U2026" "@\$p";
    sudo -u "${REAL_NAME}" sudo mdutil -i off -a
    # sudo -u "${REAL_NAME}" defaults import com.apple.controlcenter /tmp/com.apple.controlcenter.plist
    # sudo -u "${REAL_NAME}" defaults write "/Users/${REAL_NAME}/Library/Preferences/.GlobalPreferences MultipleSessionEnabled" -bool 'YES'
    # sudo -u mdutil -i off -a
    # sudo dscl . -create "/Users/${REAL_NAME}" UserShell "${USERSHELL}"
    sudo -u "${REAL_NAME}" "whoami"
done
#############################3

Disable apps from going to sleep at all

This command will prevent applications from sleeping, completely in the background.

You can verify this using the top command and an App should never go into sleeping state.

This increases RAM usage, but means your apps, like Xcode, will spring into action.

sudo -u "${REAL_NAME}" sudo defaults write NSGlobalDomain NSAppSleepDisabled -bool YES

osx-optimizer's People

Contributors

sickcodes avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.