Apple Mac

In 2017 I started using a MacBook Pro, having not used an Apple Mac since 1995 when I was last doing development work on the platform. Needless to say it took some adjusting and getting used to, so this is what I learnt and some helpful, hopefully, notes.

I started with a MacBook Pro (Retina, 15-inch, Mid 2015), which I have to say was a very nice and well made machine. Then in December 2017 I switched to a MacBook Pro (15-inch, 2016) which is all USB-C and has the Touch Bar, however it does have the problematic keyboard, see Keyboard Service Program for MacBook, MacBook Air, and MacBook Pro - Apple Support. Next in April 2022 I migrated to a MacBook Pro (16-inch, 2019) - Technical Specifications (UK) because the problematic keyboard was indeed a problem, however I also needed a 32GB machine.

If you want to try a Mac out but don't want to commit then have a look at MacinCloud - Rent a Mac in the Cloud! - Mac in Cloud, you won't get the full experience but it will give you a good idea of what a Mac is like and you can use this for cross platform development with a Mac if necessary.

Hints & Tips

Finder Sorting: if you want Finder to always sort with folders first then open a Finder window, open Preferences and select Advanced, the option is there
Show Hidden Files: in an Open/Save Dialog or in Finder press Cmd+Shift+Period to display hidden files and directories
Print Screen: press Cmd+Shift+3 to get your screen saved as a PNG on the Desktop
Print Part Screen: press Cmd+Shift+4, you then get a cross-hair to select the part you want, or press space when the cross-hair shows to get a camera so you can select a Window. See How to take a screenshot on your Mac - Apple Support for more details and options
Screenshot Utility if you press Cmd+Shift+5 you will get a powerful and flexible screenshot utility, this was introduced in macOS Mojave (10.14) see Take screenshots or screen recordings on Mac - Apple Support
Delete: a Mac has the Backspace key but not Delete like Windows, press Fn+Backspace to get a Delete
Page Up: this is fn+up
Page Down: this is fn+down
Do Not Disturb: in System Preferences -> Notifications you can turn on Do Not Disturb "When mirroring to TV's and projectors", a handy option but possibly on by default
Do Not Disturb: if you "Option+Click" the "bullet list icon" in the top right hand corner of the screen then this will toggle Do Not Disturb. I have not used this, so not quite sure what it does
Flush the DNS Cache: on OS X 10.9 or higher you need to execute the following two commands:
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Hostname - you can set this via System Preferences -> Sharing, see macOS Sierra: Change your computer’s local hostname
Space Separators in Dock - no idea why Apple hid this but try this How to Group Mac App Icons More Prominently in Your Dock - Mac Rumors
Typing Emojis - press Ctrl+Cmd+Space and a dialog will appear, then just click whatever you want to insert
Accented Characters - very similar to getting an emoji, hit Ctrl+Cmd+Space but this time click the grey icon in the top right, this will expand the emoji dialog to give more options, including adding things to your favourites but vitally "Latin" when you can find characters with accents on. Another option is to hold the letter down on the keyboard, so press the letter e and hold it, then press the number of the accent you want
Terminal - if you need to move the cursor a long way on a command line, then Option+Click can save a lot of left arrow keypresses

It is worth noting that most Useful Linux Commands will also work on a Mac, although there might be minor differences in options or versions, for example, see curl.

Desktops

If you wish to quickly switch desktops then Ctrl+Left or Ctrl+Right work very nicely.

Handy Articles

Some useful articles to help you learn about your Mac:
How to use the Touch Bar on your MacBook Pro - Apple Support
How to use the Force Touch trackpad - Apple Support
Mac keyboard shortcuts - Apple Support
Mac tips for Windows switchers - Apple Support

App Store

Some people like to stay within the "walled garden" that is the world of Apple and their App Store, others find this too restrictive. There are apps, like Slack that you can get from Apple's App Store or direct. With some though, it is worth noting they have a different release policy, so at the moment, the App Store is one minor version behind the direct download.

When I first wanted to remove an app installed via the App Store, I could not see an obvious/official way of doing it, however How to delete apps on your Mac - Apple Support explains your options. Once done, you should notice the icon next to the app change in the App Store.

Finder

File Move

It took me a while to discover how to move a file with Finder, basically there are two ways:

  1. Open a second Finder window Cmd+N or select "New Finder Window" from the File Menu and then drag and drop the file
  2. In Finder copy the file (Cmd+C, Edit menu or Context menu) and then change to the new folder and click the Edit Menu and press the option key, such that paste becomes move, or do similar with the context menu, or press Option+Cmd+V, if you can remember that

I started using the first way but now the second seems more natural.

Open a Folder

You would think that opening a folder is easy, well it is yes.... however sometimes I find that I have a long directory structure in the clipboard and want to get that in a finder window. It took me a while but I figure out a few ways of doing this.

  1. Open Finder, select "Go to folder..." from the "Go" menu, paste in the directory
  2. Open Finder, press Cmd+Shift+G, paste in the directory
  3. Open a Terminal, type open " press Cmd+V to paste, type " and then press enter
  4. Open a Terminal, type open "`pbpaste`", press enter and voila

Security

See Apple security updates - Apple Support for details about security updates

It is recommended that you encrypt your hard drive, see FileVault for some details on this.

Privacy

A good summary of Apple Privacy is available via Apple privacy portal lets you see everything it knows about you – Naked Security.

Battery

If you go to "Apple Menu" -> "About This Mac" -> "System Report" -> "Hardware" -> "Power" -> "Health Information" you will see a "Cycle Count" and "Condition", all being well the condition will be "Normal".

File System

In September 2017 Apple release macOS High Sierra, which was the first shipping of APFS, read more details on this at A ZFS developer’s analysis of the good and bad in Apple’s new APFS file system | Ars Technica.

See FileVault if you need help with disk encryption.

Setting Up...

See Homebrew for macOS for information on using brew.

Some people prefer The MacPorts Project -- Home which was around before Homebrew and is still used and supported.

Wiping your Mac

Sometimes you need to wipe your Mac and know that it is wiped and clean for someone else to use. In this case, have a read of What to do before you sell or give away your Mac - Apple Support.

Recovering your Mac

So, after wiping your Mac above, you will probably want reset it. In which case, just after hitting the power button press and hold down Cmd+R and the recovery console will appear or for a wiped Mac, it will ask for a wireless network and then start setting things up.

External Display

With my newer MacBook Pro it only had USB-C connectors and hence I needed an adapter to connect it to external displays. When doing this macOS defaults to "Default for display", which in my experience is some low resolution that is not usable, hence the "Scaled" option is much better. However sometimes the list of choices is very limited and not what you know to be the native resolution of the device. In which case, switch back to "Default for display" and then press and hold the "Option" key while clicking "Scaled", then macOS will show you a much greater range of options for the resolution. Simple, when you know how.

Dashboard

The macOS Dashboard seems to have lovers and haters. I think it is okay, however my issue was I could not close it! I opened the "Launchpad" and clicked "Dashboard" and then it appears as a "space" but not one you can close, for some reason, well done Apple! The only way I have found to close it is to open "System Preferences" from the Apple menu, open "Mission Control" and set Dashboard to Off rather than Space and then it goes.

Certificates

If you want to see what certificates you have installed and for what purpose then load "Keychain Access". In the "Launchpad" this is under "Other" but can you just start typing to search for it. if you just want to see the trusted root certificates then use /System/Library/Security/Certificates.bundle/Contents/Resources/TrustStore.html in your browser, although your browser may not open that link for security reasons.

Updates

When doing a macOS upgrade I suggest you allow an hour and are plugged into the mains before you start.

Generally macOS updates work smoothly, however after upgrading from macOS High Sierra to macOS Mojave I found that git stopped working. It seems you need to accept the license agreement again. To get git working again I needed to do the following:
xcode-select --install
This worked fine for me and fixed the problem, although some people suggest they needed "xcode-select --reset" instead.

There are times when you need to get an update from an old version of macOS but avoid going to the very latest. Old versions are needed sometimes and as long as they are getting security updates then all is well. I have, for various reasons found myself on Mojave (10.14), after Catalina (10.15) and Big Sur (11) have been released. The issue is than that Software Update wants to take you to Big Sur but getting Catalina is possible, still but trickier, in short you need to visit How to get old versions of macOS – Apple Support. There are a couple of things to note here, firstly there are region specific versions of this page so if you need something other than "en-gb" you will need to find the right one, secondly I found this worked best in Safari as the link you click takes you to the App Store. The odd thing is you cannot search in the App Store, you need to go via the support page.

Time Machine

Whilst Time Machine is useful, I find its lack of detailed explanation of what it is doing frustrating. Fortunately I have found a kind of solution, in that you can search system log, as follows:
log show --predicate 'subsystem == "com.apple.TimeMachine"' --info --last 1h
The part at the end can be adjusted to change how far back you want to look.

I have not used Time Machine for backing up, myself. However I noticed recently a friend could not restore his backup due to some apps producing corrupt App Store receipt files, which in 2018 Time Machine did not handle gracefully during restore, it would just stop. The solution is at Solution for Time Machine ‘error while restoring from the backup’ | Harry Fear's Blog which goes through how you access and modify a backup.

System Information

If you open a terminal window and run system_profiler you will be able to get a lot of system information. Running the command on its own gives almost too much output, so I would suggest redirecting the output to a file. The following are more useful examples:
system_profiler SPHardwareDataType - this shows model, cpu and serial number
system_profiler SPSoftwareDataType - this shows system software details, so macOS version with build, kernel information, as well as host and boot details
You can get the macOS build number, or rather identifier, via the "About this Mac" dialog, which is on the main Apple menu, just open the dialog and click on the word "Version" and it appears.

Network Information

As you might expect, there are some thing you can do visually and many more you can do at the command line. In System Preferences you can use Network to configure everything, there is also the Network Utility app available via Spotlight etc.

Alternatively you can do a lot of things at the command line, here are some examples:
scutil --dns - display DNS config
scutil --get ComputerName - will show something like "Geoff's MacBook Pro"
scutil --get LocalHostName - will show something like "Geoffs-MacBook-Pro"
scutil --get HostName - may just say "Not set"
scutil --proxy - display proxy info
system_profiler SPNetworkDataType - this shows basic network information, both hardware and address details
networksetup -listallhardwareports - shows just adapter name and MAC address
hostname - will show something like "Geoffs-MacBook-Pro.local"
defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName - show the computer name on NetBIOS

File Checksums

It is good practice to check downloaded files, specifically that the checksum of the downloaded file matches what the author published. So after downloading the file you can get SHA or SHA256 checksums as follows:
shasum downloadedfile.dmg - this gives the SHA checksum
shasum -a 256 downloadedfile.dmg - this gives the SHA256 checksum
There are MD5 checksums but these have been proved to be insufficient.

Jamf

The Jamf Pro | Mobile Security | Casper Suite | Jamf product provides "device management" for Apple products, both macOS and iOS. If have a Jamf managed device then you can see which Jamf Server managed your Mac by executing the following command:
sudo jamf recon

SIP

Modern macOS has a thing called System Integrity Protection, more about which you can read at About System Integrity Protection on your Mac - Apple Support. If you want to check it is enabled then execute the following command:
csrutil status

Command Line Interface

Zip Files

There are two command line utilities for putting files into a zip archive and getting them out again. Specifically zip and unzip, here are some examples:
zip archive.zip filename.ext - this will add a file to a new archive, you can use fully qualified paths of course
zip -r /tmp/temp_archive.zip /User/username/Downloads/ - this will put the Downloads directory and all its contents in the specified archive, -r means recurse all subdirectories

Networking

The networksetup utility is supposed to be a wrapper for ifconfig, but it does not do everything ifconfig does. However it is the best option for doing what it does.

  • networksetup -listallhardwareports - lists all of the network adapters, which handily includes the MAC address and device id used by ifconfig
  • networksetup -listpreferredwirelessnetworks en0 - list all the wireless networks for en0