About bash_profile and bashrc on macOS – Scripting OS X

Note: bash_profile is completely different from configuration profiles. Learn more about Configuration Profiles in my book: ‘Property Lists, Preferences and Profiles for Apple Administrators’ Note:…

Source: About bash_profile and bashrc on macOS – Scripting OS X


How to fix gyp: No Xcode or CLT version detected

xcode-select -print-path
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Restart macOS Screen Sharing Service via SSH

Sometimes screen sharing service on your headless Mac mini may crash. This should fix the issue:

sudo launchctl unload /System/Library/LaunchDaemons/  
sudo launchctl load -w /System/Library/LaunchDaemons/

Install OptiFine for Minecraft without Installing Java Runtime on macOS

You can simply use Minecraft bundled Java runtime to install OptiFine.

~/Library/Application\ Support/minecraft/runtime/jre-x64/jre.bundle/Contents/Home/bin/java -jar /path/to/OptiFine_1.14.4_HD_U_F3.jar

macOS Bug: Connecting to another Mac via SMB protocol results in client hanging indefinitely at shutdown or restart

How to force SMB2, which actually doesn’t work for me:

10.14.3 – SMB3 Performance Issues – Force SMB2

Related discussion on Apple Communities

Computers Won’t Shut Down After Connecting To Server

Bug reports on Apple Radar:

How to submit sysdiagnose:

  • Command + Option + Shift+ Control + Period (.)
  • Or in Terminal: sudo sysdiagnose

Note: The sysdiagnose process can take 10 minutes to complete. Once finished, the folder /private/var/tmp/ should appear automatically in the Finder and the sysdiagnose file there will look similar to this:


View active SMB connection status:

smbutil statshares -a

Enable TRIM Support for Third-party SSDs on macOS Mojave

sudo trimforce enable

Source: Mac OS X 10.10.4 Supports TRIM for Third-Party SSD Hard Drives


How to Rebuild a RAID 1 Setup (WD My Book Duo) on macOS, the Right Way

This guide will talk about rebuilding a failed RAID 1 disk with WD My Book Duo on macOS, it should also works on Thunderbolt Duo or other RAID 1 setup.

Many other guides only tell you how to replace the whole two disks without restoring / rebuilding data for this common situation:

In a common case, your RAID 1 setup could fail with only one defective disk, while the other is online. If you see this status on your macOS:

  1. Buy a brand new disk, same size and model as your failed disk.
  2. Reboot your mac in recovery mode, this step is very important to make sure your disks are not used by macOS.
  3. In recovery boot, open Disk Utility.
  4. Rename your RAID set, for example if your RAID set is External-Raid, rename it to something like External-Raid-Rebuild or just some names different than your original, this is the most important step to make sure your RAID set wouldn’t be using after entering macOS system.
  5. Restart your system in normal mode.
  6. Login to your system, then open Disk Utility, congrats, you will see the new disk is now rebuilding.

Other notes:

  • Restraint editing/adding/removing files on your RAID set while rebuilding.
  • The rebuild process could take hours depends on your disk size (10-20 hours for a 4 TB + 4 TB RAID 1 setup).
  • After the rebuild complete, you can rename your RAID volume name back to original.

This is not the only way to rebuild your RAID with a failed disk. According to WD documentation, you can power on your My Book Duo without connecting to macOS (remove the thunderbolt cable), then the My Book Duo should rebuild it automatically. However, it’s really hard to know when the rebuild process will finish, there’s no special indicator status for this situation, so I prefer rebuilding in macOS. This could be the best method for me.


Change Default Screen Sharing / VNC Port on macOS

sudo vi /etc/services

Search 5900 and edit it.

sudo launchctl unload /System/Library/LaunchDaemons/
sudo launchctl load /System/Library/LaunchDaemons/

Apple Autofs.pdf

It was available at



S/MIME for Apple Mail, The Right Way (DigiCert Version)

Install it on macOS:

  • Download cert bundle (.p7b) or individual certs (zipped) from DigiCert
  • Double click to install them on macOS Keychain Access

Install it on iOS:

  • Open Keychain Access, select category My Certificates
  • Right click and choose Export, select format .p12 (Make sure to export your cert into .p12, this will contain private key for iOS to send encrypted emails)
  • Email it with your individual certs (root CAs from DigiCert) and install them on iOS
  • Select this cert under email account settings